
bin/kernel:     file format elf64-littleriscv


Disassembly of section .text:

ffffffffc0200000 <kern_entry>:
    .globl kern_entry
kern_entry:
    # a0: hartid
    # a1: dtb physical address
    # save hartid and dtb address
    la t0, boot_hartid
ffffffffc0200000:	00007297          	auipc	t0,0x7
ffffffffc0200004:	00028293          	mv	t0,t0
    sd a0, 0(t0)
ffffffffc0200008:	00a2b023          	sd	a0,0(t0) # ffffffffc0207000 <boot_hartid>
    la t0, boot_dtb
ffffffffc020000c:	00007297          	auipc	t0,0x7
ffffffffc0200010:	ffc28293          	addi	t0,t0,-4 # ffffffffc0207008 <boot_dtb>
    sd a1, 0(t0)
ffffffffc0200014:	00b2b023          	sd	a1,0(t0)

    # t0 := 三级页表的虚拟地址
    lui     t0, %hi(boot_page_table_sv39)
ffffffffc0200018:	c02062b7          	lui	t0,0xc0206
    # t1 := 0xffffffff40000000 即虚实映射偏移量
    li      t1, 0xffffffffc0000000 - 0x80000000
ffffffffc020001c:	ffd0031b          	addiw	t1,zero,-3
ffffffffc0200020:	037a                	slli	t1,t1,0x1e
    # t0 减去虚实映射偏移量 0xffffffff40000000，变为三级页表的物理地址
    sub     t0, t0, t1
ffffffffc0200022:	406282b3          	sub	t0,t0,t1
    # t0 >>= 12，变为三级页表的物理页号
    srli    t0, t0, 12
ffffffffc0200026:	00c2d293          	srli	t0,t0,0xc

    # t1 := 8 << 60，设置 satp 的 MODE 字段为 Sv39
    li      t1, 8 << 60
ffffffffc020002a:	fff0031b          	addiw	t1,zero,-1
ffffffffc020002e:	137e                	slli	t1,t1,0x3f
    # 将刚才计算出的预设三级页表物理页号附加到 satp 中
    or      t0, t0, t1
ffffffffc0200030:	0062e2b3          	or	t0,t0,t1
    # 将算出的 t0(即新的MODE|页表基址物理页号) 覆盖到 satp 中
    csrw    satp, t0
ffffffffc0200034:	18029073          	csrw	satp,t0
    # 使用 sfence.vma 指令刷新 TLB
    sfence.vma
ffffffffc0200038:	12000073          	sfence.vma
    # 从此，我们给内核搭建出了一个完美的虚拟内存空间！
    #nop # 可能映射的位置有些bug。。插入一个nop
    
    # 我们在虚拟内存空间中：随意将 sp 设置为虚拟地址！
    lui sp, %hi(bootstacktop)
ffffffffc020003c:	c0206137          	lui	sp,0xc0206

    # 我们在虚拟内存空间中：随意跳转到虚拟地址！
    # 1. 使用临时寄存器 t1 计算栈顶的精确地址
    lui t1, %hi(bootstacktop)
ffffffffc0200040:	c0206337          	lui	t1,0xc0206
    addi t1, t1, %lo(bootstacktop)
ffffffffc0200044:	00030313          	mv	t1,t1
    # 2. 将精确地址一次性地、安全地传给 sp
    mv sp, t1
ffffffffc0200048:	811a                	mv	sp,t1
    # 现在栈指针已经完美设置，可以安全地调用任何C函数了
    # 然后跳转到 kern_init (不再返回)
    lui t0, %hi(kern_init)
ffffffffc020004a:	c02002b7          	lui	t0,0xc0200
    addi t0, t0, %lo(kern_init)
ffffffffc020004e:	05428293          	addi	t0,t0,84 # ffffffffc0200054 <kern_init>
    jr t0
ffffffffc0200052:	8282                	jr	t0

ffffffffc0200054 <kern_init>:
void grade_backtrace(void);

int kern_init(void) {
    extern char edata[], end[];
    // 先清零 BSS，再读取并保存 DTB 的内存信息，避免被清零覆盖
    memset(edata, 0, end - edata);
ffffffffc0200054:	00007517          	auipc	a0,0x7
ffffffffc0200058:	fd450513          	addi	a0,a0,-44 # ffffffffc0207028 <free_area>
ffffffffc020005c:	00007617          	auipc	a2,0x7
ffffffffc0200060:	44460613          	addi	a2,a2,1092 # ffffffffc02074a0 <end>
int kern_init(void) {
ffffffffc0200064:	1141                	addi	sp,sp,-16
    memset(edata, 0, end - edata);
ffffffffc0200066:	8e09                	sub	a2,a2,a0
ffffffffc0200068:	4581                	li	a1,0
int kern_init(void) {
ffffffffc020006a:	e406                	sd	ra,8(sp)
    memset(edata, 0, end - edata);
ffffffffc020006c:	205010ef          	jal	ra,ffffffffc0201a70 <memset>
    dtb_init();
ffffffffc0200070:	41e000ef          	jal	ra,ffffffffc020048e <dtb_init>
    cons_init();  // init the console
ffffffffc0200074:	752000ef          	jal	ra,ffffffffc02007c6 <cons_init>
    const char *message = "(THU.CST) os is loading ...\0";
    //cprintf("%s\n\n", message);
    cputs(message);
ffffffffc0200078:	00002517          	auipc	a0,0x2
ffffffffc020007c:	f1850513          	addi	a0,a0,-232 # ffffffffc0201f90 <etext+0x2>
ffffffffc0200080:	098000ef          	jal	ra,ffffffffc0200118 <cputs>

    print_kerninfo();
ffffffffc0200084:	140000ef          	jal	ra,ffffffffc02001c4 <print_kerninfo>

    // grade_backtrace();
    idt_init();  // init interrupt descriptor table
ffffffffc0200088:	758000ef          	jal	ra,ffffffffc02007e0 <idt_init>

    pmm_init();  // init physical memory management
ffffffffc020008c:	49b000ef          	jal	ra,ffffffffc0200d26 <pmm_init>

    idt_init();  // init interrupt descriptor table
ffffffffc0200090:	750000ef          	jal	ra,ffffffffc02007e0 <idt_init>

    clock_init();   // init clock interrupt
ffffffffc0200094:	6f0000ef          	jal	ra,ffffffffc0200784 <clock_init>
    intr_enable();  // enable irq interrupt
ffffffffc0200098:	73c000ef          	jal	ra,ffffffffc02007d4 <intr_enable>
ffffffffc020009c:	00100073          	ebreak

    // ★ 一次性触发的 32 位断点与 32 位非法指令
    asm volatile(".word 0x00100073");   // 断点指令
ffffffffc02000a0:	ffff                	0xffff
ffffffffc02000a2:	ffff                	0xffff
    asm volatile(".word 0xffffffff");   // 非法指令

    /* do nothing */
    while (1)
ffffffffc02000a4:	a001                	j	ffffffffc02000a4 <kern_init+0x50>

ffffffffc02000a6 <cputch>:
/* *
 * cputch - writes a single character @c to stdout, and it will
 * increace the value of counter pointed by @cnt.
 * */
static void
cputch(int c, int *cnt) {
ffffffffc02000a6:	1141                	addi	sp,sp,-16
ffffffffc02000a8:	e022                	sd	s0,0(sp)
ffffffffc02000aa:	e406                	sd	ra,8(sp)
ffffffffc02000ac:	842e                	mv	s0,a1
    cons_putc(c);
ffffffffc02000ae:	71a000ef          	jal	ra,ffffffffc02007c8 <cons_putc>
    (*cnt) ++;
ffffffffc02000b2:	401c                	lw	a5,0(s0)
}
ffffffffc02000b4:	60a2                	ld	ra,8(sp)
    (*cnt) ++;
ffffffffc02000b6:	2785                	addiw	a5,a5,1
ffffffffc02000b8:	c01c                	sw	a5,0(s0)
}
ffffffffc02000ba:	6402                	ld	s0,0(sp)
ffffffffc02000bc:	0141                	addi	sp,sp,16
ffffffffc02000be:	8082                	ret

ffffffffc02000c0 <vcprintf>:
 *
 * Call this function if you are already dealing with a va_list.
 * Or you probably want cprintf() instead.
 * */
int
vcprintf(const char *fmt, va_list ap) {
ffffffffc02000c0:	1101                	addi	sp,sp,-32
ffffffffc02000c2:	862a                	mv	a2,a0
ffffffffc02000c4:	86ae                	mv	a3,a1
    int cnt = 0;
    vprintfmt((void*)cputch, &cnt, fmt, ap);
ffffffffc02000c6:	00000517          	auipc	a0,0x0
ffffffffc02000ca:	fe050513          	addi	a0,a0,-32 # ffffffffc02000a6 <cputch>
ffffffffc02000ce:	006c                	addi	a1,sp,12
vcprintf(const char *fmt, va_list ap) {
ffffffffc02000d0:	ec06                	sd	ra,24(sp)
    int cnt = 0;
ffffffffc02000d2:	c602                	sw	zero,12(sp)
    vprintfmt((void*)cputch, &cnt, fmt, ap);
ffffffffc02000d4:	21b010ef          	jal	ra,ffffffffc0201aee <vprintfmt>
    return cnt;
}
ffffffffc02000d8:	60e2                	ld	ra,24(sp)
ffffffffc02000da:	4532                	lw	a0,12(sp)
ffffffffc02000dc:	6105                	addi	sp,sp,32
ffffffffc02000de:	8082                	ret

ffffffffc02000e0 <cprintf>:
 *
 * The return value is the number of characters which would be
 * written to stdout.
 * */
int
cprintf(const char *fmt, ...) {
ffffffffc02000e0:	711d                	addi	sp,sp,-96
    va_list ap;
    int cnt;
    va_start(ap, fmt);
ffffffffc02000e2:	02810313          	addi	t1,sp,40 # ffffffffc0206028 <boot_page_table_sv39+0x28>
cprintf(const char *fmt, ...) {
ffffffffc02000e6:	8e2a                	mv	t3,a0
ffffffffc02000e8:	f42e                	sd	a1,40(sp)
ffffffffc02000ea:	f832                	sd	a2,48(sp)
ffffffffc02000ec:	fc36                	sd	a3,56(sp)
    vprintfmt((void*)cputch, &cnt, fmt, ap);
ffffffffc02000ee:	00000517          	auipc	a0,0x0
ffffffffc02000f2:	fb850513          	addi	a0,a0,-72 # ffffffffc02000a6 <cputch>
ffffffffc02000f6:	004c                	addi	a1,sp,4
ffffffffc02000f8:	869a                	mv	a3,t1
ffffffffc02000fa:	8672                	mv	a2,t3
cprintf(const char *fmt, ...) {
ffffffffc02000fc:	ec06                	sd	ra,24(sp)
ffffffffc02000fe:	e0ba                	sd	a4,64(sp)
ffffffffc0200100:	e4be                	sd	a5,72(sp)
ffffffffc0200102:	e8c2                	sd	a6,80(sp)
ffffffffc0200104:	ecc6                	sd	a7,88(sp)
    va_start(ap, fmt);
ffffffffc0200106:	e41a                	sd	t1,8(sp)
    int cnt = 0;
ffffffffc0200108:	c202                	sw	zero,4(sp)
    vprintfmt((void*)cputch, &cnt, fmt, ap);
ffffffffc020010a:	1e5010ef          	jal	ra,ffffffffc0201aee <vprintfmt>
    cnt = vcprintf(fmt, ap);
    va_end(ap);
    return cnt;
}
ffffffffc020010e:	60e2                	ld	ra,24(sp)
ffffffffc0200110:	4512                	lw	a0,4(sp)
ffffffffc0200112:	6125                	addi	sp,sp,96
ffffffffc0200114:	8082                	ret

ffffffffc0200116 <cputchar>:

/* cputchar - writes a single character to stdout */
void
cputchar(int c) {
    cons_putc(c);
ffffffffc0200116:	ad4d                	j	ffffffffc02007c8 <cons_putc>

ffffffffc0200118 <cputs>:
/* *
 * cputs- writes the string pointed by @str to stdout and
 * appends a newline character.
 * */
int
cputs(const char *str) {
ffffffffc0200118:	1101                	addi	sp,sp,-32
ffffffffc020011a:	e822                	sd	s0,16(sp)
ffffffffc020011c:	ec06                	sd	ra,24(sp)
ffffffffc020011e:	e426                	sd	s1,8(sp)
ffffffffc0200120:	842a                	mv	s0,a0
    int cnt = 0;
    char c;
    while ((c = *str ++) != '\0') {
ffffffffc0200122:	00054503          	lbu	a0,0(a0)
ffffffffc0200126:	c51d                	beqz	a0,ffffffffc0200154 <cputs+0x3c>
ffffffffc0200128:	0405                	addi	s0,s0,1
ffffffffc020012a:	4485                	li	s1,1
ffffffffc020012c:	9c81                	subw	s1,s1,s0
    cons_putc(c);
ffffffffc020012e:	69a000ef          	jal	ra,ffffffffc02007c8 <cons_putc>
    while ((c = *str ++) != '\0') {
ffffffffc0200132:	00044503          	lbu	a0,0(s0)
ffffffffc0200136:	008487bb          	addw	a5,s1,s0
ffffffffc020013a:	0405                	addi	s0,s0,1
ffffffffc020013c:	f96d                	bnez	a0,ffffffffc020012e <cputs+0x16>
ffffffffc020013e:	0017841b          	addiw	s0,a5,1
    cons_putc(c);
ffffffffc0200142:	4529                	li	a0,10
ffffffffc0200144:	684000ef          	jal	ra,ffffffffc02007c8 <cons_putc>
        cputch(c, &cnt);
    }
    cputch('\n', &cnt);
    return cnt;
}
ffffffffc0200148:	60e2                	ld	ra,24(sp)
ffffffffc020014a:	8522                	mv	a0,s0
ffffffffc020014c:	6442                	ld	s0,16(sp)
ffffffffc020014e:	64a2                	ld	s1,8(sp)
ffffffffc0200150:	6105                	addi	sp,sp,32
ffffffffc0200152:	8082                	ret
    while ((c = *str ++) != '\0') {
ffffffffc0200154:	4405                	li	s0,1
ffffffffc0200156:	b7f5                	j	ffffffffc0200142 <cputs+0x2a>

ffffffffc0200158 <getchar>:

/* getchar - reads a single non-zero character from stdin */
int
getchar(void) {
ffffffffc0200158:	1141                	addi	sp,sp,-16
ffffffffc020015a:	e406                	sd	ra,8(sp)
    int c;
    while ((c = cons_getc()) == 0)
ffffffffc020015c:	674000ef          	jal	ra,ffffffffc02007d0 <cons_getc>
ffffffffc0200160:	dd75                	beqz	a0,ffffffffc020015c <getchar+0x4>
        /* do nothing */;
    return c;
}
ffffffffc0200162:	60a2                	ld	ra,8(sp)
ffffffffc0200164:	0141                	addi	sp,sp,16
ffffffffc0200166:	8082                	ret

ffffffffc0200168 <__panic>:
 * __panic - __panic is called on unresolvable fatal errors. it prints
 * "panic: 'message'", and then enters the kernel monitor.
 * */
void
__panic(const char *file, int line, const char *fmt, ...) {
    if (is_panic) {
ffffffffc0200168:	00007317          	auipc	t1,0x7
ffffffffc020016c:	2d830313          	addi	t1,t1,728 # ffffffffc0207440 <is_panic>
ffffffffc0200170:	00032e03          	lw	t3,0(t1)
__panic(const char *file, int line, const char *fmt, ...) {
ffffffffc0200174:	715d                	addi	sp,sp,-80
ffffffffc0200176:	ec06                	sd	ra,24(sp)
ffffffffc0200178:	e822                	sd	s0,16(sp)
ffffffffc020017a:	f436                	sd	a3,40(sp)
ffffffffc020017c:	f83a                	sd	a4,48(sp)
ffffffffc020017e:	fc3e                	sd	a5,56(sp)
ffffffffc0200180:	e0c2                	sd	a6,64(sp)
ffffffffc0200182:	e4c6                	sd	a7,72(sp)
    if (is_panic) {
ffffffffc0200184:	020e1a63          	bnez	t3,ffffffffc02001b8 <__panic+0x50>
        goto panic_dead;
    }
    is_panic = 1;
ffffffffc0200188:	4785                	li	a5,1
ffffffffc020018a:	00f32023          	sw	a5,0(t1)

    // print the 'message'
    va_list ap;
    va_start(ap, fmt);
ffffffffc020018e:	8432                	mv	s0,a2
ffffffffc0200190:	103c                	addi	a5,sp,40
    cprintf("kernel panic at %s:%d:\n    ", file, line);
ffffffffc0200192:	862e                	mv	a2,a1
ffffffffc0200194:	85aa                	mv	a1,a0
ffffffffc0200196:	00002517          	auipc	a0,0x2
ffffffffc020019a:	e1a50513          	addi	a0,a0,-486 # ffffffffc0201fb0 <etext+0x22>
    va_start(ap, fmt);
ffffffffc020019e:	e43e                	sd	a5,8(sp)
    cprintf("kernel panic at %s:%d:\n    ", file, line);
ffffffffc02001a0:	f41ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    vcprintf(fmt, ap);
ffffffffc02001a4:	65a2                	ld	a1,8(sp)
ffffffffc02001a6:	8522                	mv	a0,s0
ffffffffc02001a8:	f19ff0ef          	jal	ra,ffffffffc02000c0 <vcprintf>
    cprintf("\n");
ffffffffc02001ac:	00002517          	auipc	a0,0x2
ffffffffc02001b0:	eec50513          	addi	a0,a0,-276 # ffffffffc0202098 <etext+0x10a>
ffffffffc02001b4:	f2dff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    va_end(ap);

panic_dead:
    intr_disable();
ffffffffc02001b8:	622000ef          	jal	ra,ffffffffc02007da <intr_disable>
    while (1) {
        kmonitor(NULL);
ffffffffc02001bc:	4501                	li	a0,0
ffffffffc02001be:	130000ef          	jal	ra,ffffffffc02002ee <kmonitor>
    while (1) {
ffffffffc02001c2:	bfed                	j	ffffffffc02001bc <__panic+0x54>

ffffffffc02001c4 <print_kerninfo>:
/* *
 * print_kerninfo - print the information about kernel, including the location
 * of kernel entry, the start addresses of data and text segements, the start
 * address of free memory and how many memory that kernel has used.
 * */
void print_kerninfo(void) {
ffffffffc02001c4:	1141                	addi	sp,sp,-16
    extern char etext[], edata[], end[], kern_init[];
    cprintf("Special kernel symbols:\n");
ffffffffc02001c6:	00002517          	auipc	a0,0x2
ffffffffc02001ca:	e0a50513          	addi	a0,a0,-502 # ffffffffc0201fd0 <etext+0x42>
void print_kerninfo(void) {
ffffffffc02001ce:	e406                	sd	ra,8(sp)
    cprintf("Special kernel symbols:\n");
ffffffffc02001d0:	f11ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  entry  0x%016lx (virtual)\n", kern_init);
ffffffffc02001d4:	00000597          	auipc	a1,0x0
ffffffffc02001d8:	e8058593          	addi	a1,a1,-384 # ffffffffc0200054 <kern_init>
ffffffffc02001dc:	00002517          	auipc	a0,0x2
ffffffffc02001e0:	e1450513          	addi	a0,a0,-492 # ffffffffc0201ff0 <etext+0x62>
ffffffffc02001e4:	efdff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  etext  0x%016lx (virtual)\n", etext);
ffffffffc02001e8:	00002597          	auipc	a1,0x2
ffffffffc02001ec:	da658593          	addi	a1,a1,-602 # ffffffffc0201f8e <etext>
ffffffffc02001f0:	00002517          	auipc	a0,0x2
ffffffffc02001f4:	e2050513          	addi	a0,a0,-480 # ffffffffc0202010 <etext+0x82>
ffffffffc02001f8:	ee9ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  edata  0x%016lx (virtual)\n", edata);
ffffffffc02001fc:	00007597          	auipc	a1,0x7
ffffffffc0200200:	e2c58593          	addi	a1,a1,-468 # ffffffffc0207028 <free_area>
ffffffffc0200204:	00002517          	auipc	a0,0x2
ffffffffc0200208:	e2c50513          	addi	a0,a0,-468 # ffffffffc0202030 <etext+0xa2>
ffffffffc020020c:	ed5ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  end    0x%016lx (virtual)\n", end);
ffffffffc0200210:	00007597          	auipc	a1,0x7
ffffffffc0200214:	29058593          	addi	a1,a1,656 # ffffffffc02074a0 <end>
ffffffffc0200218:	00002517          	auipc	a0,0x2
ffffffffc020021c:	e3850513          	addi	a0,a0,-456 # ffffffffc0202050 <etext+0xc2>
ffffffffc0200220:	ec1ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("Kernel executable memory footprint: %dKB\n",
            (end - kern_init + 1023) / 1024);
ffffffffc0200224:	00007597          	auipc	a1,0x7
ffffffffc0200228:	67b58593          	addi	a1,a1,1659 # ffffffffc020789f <end+0x3ff>
ffffffffc020022c:	00000797          	auipc	a5,0x0
ffffffffc0200230:	e2878793          	addi	a5,a5,-472 # ffffffffc0200054 <kern_init>
ffffffffc0200234:	40f587b3          	sub	a5,a1,a5
    cprintf("Kernel executable memory footprint: %dKB\n",
ffffffffc0200238:	43f7d593          	srai	a1,a5,0x3f
}
ffffffffc020023c:	60a2                	ld	ra,8(sp)
    cprintf("Kernel executable memory footprint: %dKB\n",
ffffffffc020023e:	3ff5f593          	andi	a1,a1,1023
ffffffffc0200242:	95be                	add	a1,a1,a5
ffffffffc0200244:	85a9                	srai	a1,a1,0xa
ffffffffc0200246:	00002517          	auipc	a0,0x2
ffffffffc020024a:	e2a50513          	addi	a0,a0,-470 # ffffffffc0202070 <etext+0xe2>
}
ffffffffc020024e:	0141                	addi	sp,sp,16
    cprintf("Kernel executable memory footprint: %dKB\n",
ffffffffc0200250:	bd41                	j	ffffffffc02000e0 <cprintf>

ffffffffc0200252 <print_stackframe>:
 * Note that, the length of ebp-chain is limited. In boot/bootasm.S, before
 * jumping
 * to the kernel entry, the value of ebp has been set to zero, that's the
 * boundary.
 * */
void print_stackframe(void) {
ffffffffc0200252:	1141                	addi	sp,sp,-16
    panic("Not Implemented!");
ffffffffc0200254:	00002617          	auipc	a2,0x2
ffffffffc0200258:	e4c60613          	addi	a2,a2,-436 # ffffffffc02020a0 <etext+0x112>
ffffffffc020025c:	04d00593          	li	a1,77
ffffffffc0200260:	00002517          	auipc	a0,0x2
ffffffffc0200264:	e5850513          	addi	a0,a0,-424 # ffffffffc02020b8 <etext+0x12a>
void print_stackframe(void) {
ffffffffc0200268:	e406                	sd	ra,8(sp)
    panic("Not Implemented!");
ffffffffc020026a:	effff0ef          	jal	ra,ffffffffc0200168 <__panic>

ffffffffc020026e <mon_help>:
    }
}

/* mon_help - print the information about mon_* functions */
int
mon_help(int argc, char **argv, struct trapframe *tf) {
ffffffffc020026e:	1141                	addi	sp,sp,-16
    int i;
    for (i = 0; i < NCOMMANDS; i ++) {
        cprintf("%s - %s\n", commands[i].name, commands[i].desc);
ffffffffc0200270:	00002617          	auipc	a2,0x2
ffffffffc0200274:	e6060613          	addi	a2,a2,-416 # ffffffffc02020d0 <etext+0x142>
ffffffffc0200278:	00002597          	auipc	a1,0x2
ffffffffc020027c:	e7858593          	addi	a1,a1,-392 # ffffffffc02020f0 <etext+0x162>
ffffffffc0200280:	00002517          	auipc	a0,0x2
ffffffffc0200284:	e7850513          	addi	a0,a0,-392 # ffffffffc02020f8 <etext+0x16a>
mon_help(int argc, char **argv, struct trapframe *tf) {
ffffffffc0200288:	e406                	sd	ra,8(sp)
        cprintf("%s - %s\n", commands[i].name, commands[i].desc);
ffffffffc020028a:	e57ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
ffffffffc020028e:	00002617          	auipc	a2,0x2
ffffffffc0200292:	e7a60613          	addi	a2,a2,-390 # ffffffffc0202108 <etext+0x17a>
ffffffffc0200296:	00002597          	auipc	a1,0x2
ffffffffc020029a:	e9a58593          	addi	a1,a1,-358 # ffffffffc0202130 <etext+0x1a2>
ffffffffc020029e:	00002517          	auipc	a0,0x2
ffffffffc02002a2:	e5a50513          	addi	a0,a0,-422 # ffffffffc02020f8 <etext+0x16a>
ffffffffc02002a6:	e3bff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
ffffffffc02002aa:	00002617          	auipc	a2,0x2
ffffffffc02002ae:	e9660613          	addi	a2,a2,-362 # ffffffffc0202140 <etext+0x1b2>
ffffffffc02002b2:	00002597          	auipc	a1,0x2
ffffffffc02002b6:	eae58593          	addi	a1,a1,-338 # ffffffffc0202160 <etext+0x1d2>
ffffffffc02002ba:	00002517          	auipc	a0,0x2
ffffffffc02002be:	e3e50513          	addi	a0,a0,-450 # ffffffffc02020f8 <etext+0x16a>
ffffffffc02002c2:	e1fff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    }
    return 0;
}
ffffffffc02002c6:	60a2                	ld	ra,8(sp)
ffffffffc02002c8:	4501                	li	a0,0
ffffffffc02002ca:	0141                	addi	sp,sp,16
ffffffffc02002cc:	8082                	ret

ffffffffc02002ce <mon_kerninfo>:
/* *
 * mon_kerninfo - call print_kerninfo in kern/debug/kdebug.c to
 * print the memory occupancy in kernel.
 * */
int
mon_kerninfo(int argc, char **argv, struct trapframe *tf) {
ffffffffc02002ce:	1141                	addi	sp,sp,-16
ffffffffc02002d0:	e406                	sd	ra,8(sp)
    print_kerninfo();
ffffffffc02002d2:	ef3ff0ef          	jal	ra,ffffffffc02001c4 <print_kerninfo>
    return 0;
}
ffffffffc02002d6:	60a2                	ld	ra,8(sp)
ffffffffc02002d8:	4501                	li	a0,0
ffffffffc02002da:	0141                	addi	sp,sp,16
ffffffffc02002dc:	8082                	ret

ffffffffc02002de <mon_backtrace>:
/* *
 * mon_backtrace - call print_stackframe in kern/debug/kdebug.c to
 * print a backtrace of the stack.
 * */
int
mon_backtrace(int argc, char **argv, struct trapframe *tf) {
ffffffffc02002de:	1141                	addi	sp,sp,-16
ffffffffc02002e0:	e406                	sd	ra,8(sp)
    print_stackframe();
ffffffffc02002e2:	f71ff0ef          	jal	ra,ffffffffc0200252 <print_stackframe>
    return 0;
}
ffffffffc02002e6:	60a2                	ld	ra,8(sp)
ffffffffc02002e8:	4501                	li	a0,0
ffffffffc02002ea:	0141                	addi	sp,sp,16
ffffffffc02002ec:	8082                	ret

ffffffffc02002ee <kmonitor>:
kmonitor(struct trapframe *tf) {
ffffffffc02002ee:	7115                	addi	sp,sp,-224
ffffffffc02002f0:	e962                	sd	s8,144(sp)
ffffffffc02002f2:	8c2a                	mv	s8,a0
    cprintf("Welcome to the kernel debug monitor!!\n");
ffffffffc02002f4:	00002517          	auipc	a0,0x2
ffffffffc02002f8:	e7c50513          	addi	a0,a0,-388 # ffffffffc0202170 <etext+0x1e2>
kmonitor(struct trapframe *tf) {
ffffffffc02002fc:	ed86                	sd	ra,216(sp)
ffffffffc02002fe:	e9a2                	sd	s0,208(sp)
ffffffffc0200300:	e5a6                	sd	s1,200(sp)
ffffffffc0200302:	e1ca                	sd	s2,192(sp)
ffffffffc0200304:	fd4e                	sd	s3,184(sp)
ffffffffc0200306:	f952                	sd	s4,176(sp)
ffffffffc0200308:	f556                	sd	s5,168(sp)
ffffffffc020030a:	f15a                	sd	s6,160(sp)
ffffffffc020030c:	ed5e                	sd	s7,152(sp)
ffffffffc020030e:	e566                	sd	s9,136(sp)
ffffffffc0200310:	e16a                	sd	s10,128(sp)
    cprintf("Welcome to the kernel debug monitor!!\n");
ffffffffc0200312:	dcfff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("Type 'help' for a list of commands.\n");
ffffffffc0200316:	00002517          	auipc	a0,0x2
ffffffffc020031a:	e8250513          	addi	a0,a0,-382 # ffffffffc0202198 <etext+0x20a>
ffffffffc020031e:	dc3ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    if (tf != NULL) {
ffffffffc0200322:	000c0563          	beqz	s8,ffffffffc020032c <kmonitor+0x3e>
        print_trapframe(tf);
ffffffffc0200326:	8562                	mv	a0,s8
ffffffffc0200328:	698000ef          	jal	ra,ffffffffc02009c0 <print_trapframe>
ffffffffc020032c:	00002c97          	auipc	s9,0x2
ffffffffc0200330:	edcc8c93          	addi	s9,s9,-292 # ffffffffc0202208 <commands>
        if ((buf = readline("K> ")) != NULL) {
ffffffffc0200334:	00002997          	auipc	s3,0x2
ffffffffc0200338:	e8c98993          	addi	s3,s3,-372 # ffffffffc02021c0 <etext+0x232>
        while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) {
ffffffffc020033c:	00002917          	auipc	s2,0x2
ffffffffc0200340:	e8c90913          	addi	s2,s2,-372 # ffffffffc02021c8 <etext+0x23a>
        if (argc == MAXARGS - 1) {
ffffffffc0200344:	4a3d                	li	s4,15
            cprintf("Too many arguments (max %d).\n", MAXARGS);
ffffffffc0200346:	00002b17          	auipc	s6,0x2
ffffffffc020034a:	e8ab0b13          	addi	s6,s6,-374 # ffffffffc02021d0 <etext+0x242>
ffffffffc020034e:	00002a97          	auipc	s5,0x2
ffffffffc0200352:	da2a8a93          	addi	s5,s5,-606 # ffffffffc02020f0 <etext+0x162>
    for (i = 0; i < NCOMMANDS; i ++) {
ffffffffc0200356:	4b8d                	li	s7,3
        if ((buf = readline("K> ")) != NULL) {
ffffffffc0200358:	854e                	mv	a0,s3
ffffffffc020035a:	317010ef          	jal	ra,ffffffffc0201e70 <readline>
ffffffffc020035e:	842a                	mv	s0,a0
ffffffffc0200360:	dd65                	beqz	a0,ffffffffc0200358 <kmonitor+0x6a>
ffffffffc0200362:	00054583          	lbu	a1,0(a0)
    int argc = 0;
ffffffffc0200366:	4481                	li	s1,0
        while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) {
ffffffffc0200368:	c999                	beqz	a1,ffffffffc020037e <kmonitor+0x90>
ffffffffc020036a:	854a                	mv	a0,s2
ffffffffc020036c:	6ee010ef          	jal	ra,ffffffffc0201a5a <strchr>
ffffffffc0200370:	c925                	beqz	a0,ffffffffc02003e0 <kmonitor+0xf2>
            *buf ++ = '\0';
ffffffffc0200372:	00144583          	lbu	a1,1(s0)
ffffffffc0200376:	00040023          	sb	zero,0(s0)
ffffffffc020037a:	0405                	addi	s0,s0,1
        while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) {
ffffffffc020037c:	f5fd                	bnez	a1,ffffffffc020036a <kmonitor+0x7c>
    if (argc == 0) {
ffffffffc020037e:	dce9                	beqz	s1,ffffffffc0200358 <kmonitor+0x6a>
        if (strcmp(commands[i].name, argv[0]) == 0) {
ffffffffc0200380:	6582                	ld	a1,0(sp)
ffffffffc0200382:	00002d17          	auipc	s10,0x2
ffffffffc0200386:	e86d0d13          	addi	s10,s10,-378 # ffffffffc0202208 <commands>
ffffffffc020038a:	8556                	mv	a0,s5
    for (i = 0; i < NCOMMANDS; i ++) {
ffffffffc020038c:	4401                	li	s0,0
        if (strcmp(commands[i].name, argv[0]) == 0) {
ffffffffc020038e:	0d61                	addi	s10,s10,24
ffffffffc0200390:	686010ef          	jal	ra,ffffffffc0201a16 <strcmp>
ffffffffc0200394:	c919                	beqz	a0,ffffffffc02003aa <kmonitor+0xbc>
    for (i = 0; i < NCOMMANDS; i ++) {
ffffffffc0200396:	2405                	addiw	s0,s0,1
ffffffffc0200398:	09740463          	beq	s0,s7,ffffffffc0200420 <kmonitor+0x132>
ffffffffc020039c:	000d3503          	ld	a0,0(s10)
        if (strcmp(commands[i].name, argv[0]) == 0) {
ffffffffc02003a0:	6582                	ld	a1,0(sp)
ffffffffc02003a2:	0d61                	addi	s10,s10,24
ffffffffc02003a4:	672010ef          	jal	ra,ffffffffc0201a16 <strcmp>
ffffffffc02003a8:	f57d                	bnez	a0,ffffffffc0200396 <kmonitor+0xa8>
            return commands[i].func(argc - 1, argv + 1, tf);
ffffffffc02003aa:	00141793          	slli	a5,s0,0x1
ffffffffc02003ae:	97a2                	add	a5,a5,s0
ffffffffc02003b0:	078e                	slli	a5,a5,0x3
ffffffffc02003b2:	97e6                	add	a5,a5,s9
ffffffffc02003b4:	6b9c                	ld	a5,16(a5)
ffffffffc02003b6:	8662                	mv	a2,s8
ffffffffc02003b8:	002c                	addi	a1,sp,8
ffffffffc02003ba:	fff4851b          	addiw	a0,s1,-1
ffffffffc02003be:	9782                	jalr	a5
            if (runcmd(buf, tf) < 0) {
ffffffffc02003c0:	f8055ce3          	bgez	a0,ffffffffc0200358 <kmonitor+0x6a>
}
ffffffffc02003c4:	60ee                	ld	ra,216(sp)
ffffffffc02003c6:	644e                	ld	s0,208(sp)
ffffffffc02003c8:	64ae                	ld	s1,200(sp)
ffffffffc02003ca:	690e                	ld	s2,192(sp)
ffffffffc02003cc:	79ea                	ld	s3,184(sp)
ffffffffc02003ce:	7a4a                	ld	s4,176(sp)
ffffffffc02003d0:	7aaa                	ld	s5,168(sp)
ffffffffc02003d2:	7b0a                	ld	s6,160(sp)
ffffffffc02003d4:	6bea                	ld	s7,152(sp)
ffffffffc02003d6:	6c4a                	ld	s8,144(sp)
ffffffffc02003d8:	6caa                	ld	s9,136(sp)
ffffffffc02003da:	6d0a                	ld	s10,128(sp)
ffffffffc02003dc:	612d                	addi	sp,sp,224
ffffffffc02003de:	8082                	ret
        if (*buf == '\0') {
ffffffffc02003e0:	00044783          	lbu	a5,0(s0)
ffffffffc02003e4:	dfc9                	beqz	a5,ffffffffc020037e <kmonitor+0x90>
        if (argc == MAXARGS - 1) {
ffffffffc02003e6:	03448863          	beq	s1,s4,ffffffffc0200416 <kmonitor+0x128>
        argv[argc ++] = buf;
ffffffffc02003ea:	00349793          	slli	a5,s1,0x3
ffffffffc02003ee:	0118                	addi	a4,sp,128
ffffffffc02003f0:	97ba                	add	a5,a5,a4
ffffffffc02003f2:	f887b023          	sd	s0,-128(a5)
        while (*buf != '\0' && strchr(WHITESPACE, *buf) == NULL) {
ffffffffc02003f6:	00044583          	lbu	a1,0(s0)
        argv[argc ++] = buf;
ffffffffc02003fa:	2485                	addiw	s1,s1,1
        while (*buf != '\0' && strchr(WHITESPACE, *buf) == NULL) {
ffffffffc02003fc:	e591                	bnez	a1,ffffffffc0200408 <kmonitor+0x11a>
ffffffffc02003fe:	b749                	j	ffffffffc0200380 <kmonitor+0x92>
ffffffffc0200400:	00144583          	lbu	a1,1(s0)
            buf ++;
ffffffffc0200404:	0405                	addi	s0,s0,1
        while (*buf != '\0' && strchr(WHITESPACE, *buf) == NULL) {
ffffffffc0200406:	ddad                	beqz	a1,ffffffffc0200380 <kmonitor+0x92>
ffffffffc0200408:	854a                	mv	a0,s2
ffffffffc020040a:	650010ef          	jal	ra,ffffffffc0201a5a <strchr>
ffffffffc020040e:	d96d                	beqz	a0,ffffffffc0200400 <kmonitor+0x112>
ffffffffc0200410:	00044583          	lbu	a1,0(s0)
ffffffffc0200414:	bf91                	j	ffffffffc0200368 <kmonitor+0x7a>
            cprintf("Too many arguments (max %d).\n", MAXARGS);
ffffffffc0200416:	45c1                	li	a1,16
ffffffffc0200418:	855a                	mv	a0,s6
ffffffffc020041a:	cc7ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
ffffffffc020041e:	b7f1                	j	ffffffffc02003ea <kmonitor+0xfc>
    cprintf("Unknown command '%s'\n", argv[0]);
ffffffffc0200420:	6582                	ld	a1,0(sp)
ffffffffc0200422:	00002517          	auipc	a0,0x2
ffffffffc0200426:	dce50513          	addi	a0,a0,-562 # ffffffffc02021f0 <etext+0x262>
ffffffffc020042a:	cb7ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    return 0;
ffffffffc020042e:	b72d                	j	ffffffffc0200358 <kmonitor+0x6a>

ffffffffc0200430 <fdt64_to_cpu>:
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
}

static uint64_t fdt64_to_cpu(uint64_t x) {
    return ((uint64_t)fdt32_to_cpu(x & 0xffffffff) << 32) | 
           fdt32_to_cpu(x >> 32);
ffffffffc0200430:	42055693          	srai	a3,a0,0x20
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200434:	0085571b          	srliw	a4,a0,0x8
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200438:	01855e1b          	srliw	t3,a0,0x18
ffffffffc020043c:	0186d31b          	srliw	t1,a3,0x18
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200440:	00ff07b7          	lui	a5,0xff0
ffffffffc0200444:	0185189b          	slliw	a7,a0,0x18
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200448:	0105561b          	srliw	a2,a0,0x10
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc020044c:	0186981b          	slliw	a6,a3,0x18
ffffffffc0200450:	8161                	srli	a0,a0,0x18
ffffffffc0200452:	0107171b          	slliw	a4,a4,0x10
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200456:	0106d69b          	srliw	a3,a3,0x10
ffffffffc020045a:	65c1                	lui	a1,0x10
ffffffffc020045c:	15fd                	addi	a1,a1,-1
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc020045e:	8f7d                	and	a4,a4,a5
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200460:	00686833          	or	a6,a6,t1
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200464:	8fe9                	and	a5,a5,a0
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200466:	0086969b          	slliw	a3,a3,0x8
ffffffffc020046a:	01c8e8b3          	or	a7,a7,t3
ffffffffc020046e:	0086161b          	slliw	a2,a2,0x8
ffffffffc0200472:	0107e7b3          	or	a5,a5,a6
ffffffffc0200476:	8eed                	and	a3,a3,a1
ffffffffc0200478:	01176533          	or	a0,a4,a7
ffffffffc020047c:	8fd5                	or	a5,a5,a3
ffffffffc020047e:	00b67733          	and	a4,a2,a1
ffffffffc0200482:	8d59                	or	a0,a0,a4
           fdt32_to_cpu(x >> 32);
ffffffffc0200484:	1782                	slli	a5,a5,0x20
ffffffffc0200486:	9381                	srli	a5,a5,0x20
    return ((uint64_t)fdt32_to_cpu(x & 0xffffffff) << 32) | 
ffffffffc0200488:	1502                	slli	a0,a0,0x20
}
ffffffffc020048a:	8d5d                	or	a0,a0,a5
ffffffffc020048c:	8082                	ret

ffffffffc020048e <dtb_init>:

// 保存解析出的系统物理内存信息
static uint64_t memory_base = 0;
static uint64_t memory_size = 0;

void dtb_init(void) {
ffffffffc020048e:	7159                	addi	sp,sp,-112
    cprintf("DTB Init\n");
ffffffffc0200490:	00002517          	auipc	a0,0x2
ffffffffc0200494:	dc050513          	addi	a0,a0,-576 # ffffffffc0202250 <commands+0x48>
void dtb_init(void) {
ffffffffc0200498:	f486                	sd	ra,104(sp)
ffffffffc020049a:	f0a2                	sd	s0,96(sp)
ffffffffc020049c:	e0d2                	sd	s4,64(sp)
ffffffffc020049e:	eca6                	sd	s1,88(sp)
ffffffffc02004a0:	e8ca                	sd	s2,80(sp)
ffffffffc02004a2:	e4ce                	sd	s3,72(sp)
ffffffffc02004a4:	fc56                	sd	s5,56(sp)
ffffffffc02004a6:	f85a                	sd	s6,48(sp)
ffffffffc02004a8:	f45e                	sd	s7,40(sp)
ffffffffc02004aa:	f062                	sd	s8,32(sp)
ffffffffc02004ac:	ec66                	sd	s9,24(sp)
ffffffffc02004ae:	e86a                	sd	s10,16(sp)
ffffffffc02004b0:	e46e                	sd	s11,8(sp)
    cprintf("DTB Init\n");
ffffffffc02004b2:	c2fff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("HartID: %ld\n", boot_hartid);
ffffffffc02004b6:	00007597          	auipc	a1,0x7
ffffffffc02004ba:	b4a5b583          	ld	a1,-1206(a1) # ffffffffc0207000 <boot_hartid>
ffffffffc02004be:	00002517          	auipc	a0,0x2
ffffffffc02004c2:	da250513          	addi	a0,a0,-606 # ffffffffc0202260 <commands+0x58>
ffffffffc02004c6:	c1bff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("DTB Address: 0x%lx\n", boot_dtb);
ffffffffc02004ca:	00007417          	auipc	s0,0x7
ffffffffc02004ce:	b3e40413          	addi	s0,s0,-1218 # ffffffffc0207008 <boot_dtb>
ffffffffc02004d2:	600c                	ld	a1,0(s0)
ffffffffc02004d4:	00002517          	auipc	a0,0x2
ffffffffc02004d8:	d9c50513          	addi	a0,a0,-612 # ffffffffc0202270 <commands+0x68>
ffffffffc02004dc:	c05ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    
    if (boot_dtb == 0) {
ffffffffc02004e0:	00043a03          	ld	s4,0(s0)
        cprintf("Error: DTB address is null\n");
ffffffffc02004e4:	00002517          	auipc	a0,0x2
ffffffffc02004e8:	da450513          	addi	a0,a0,-604 # ffffffffc0202288 <commands+0x80>
    if (boot_dtb == 0) {
ffffffffc02004ec:	120a0363          	beqz	s4,ffffffffc0200612 <dtb_init+0x184>
        return;
    }
    
    // 转换为虚拟地址
    uintptr_t dtb_vaddr = boot_dtb + PHYSICAL_MEMORY_OFFSET;
ffffffffc02004f0:	57f5                	li	a5,-3
ffffffffc02004f2:	07fa                	slli	a5,a5,0x1e
ffffffffc02004f4:	00fa0633          	add	a2,s4,a5
    const struct fdt_header *header = (const struct fdt_header *)dtb_vaddr;
    
    // 验证DTB
    uint32_t magic = fdt32_to_cpu(header->magic);
ffffffffc02004f8:	421c                	lw	a5,0(a2)
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc02004fa:	00ff0537          	lui	a0,0xff0
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc02004fe:	0187d69b          	srliw	a3,a5,0x18
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200502:	0087d71b          	srliw	a4,a5,0x8
ffffffffc0200506:	0187959b          	slliw	a1,a5,0x18
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc020050a:	8dd5                	or	a1,a1,a3
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc020050c:	0107171b          	slliw	a4,a4,0x10
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200510:	0107d79b          	srliw	a5,a5,0x10
ffffffffc0200514:	66c1                	lui	a3,0x10
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200516:	8f69                	and	a4,a4,a0
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200518:	0087979b          	slliw	a5,a5,0x8
ffffffffc020051c:	16fd                	addi	a3,a3,-1
ffffffffc020051e:	8dd9                	or	a1,a1,a4
ffffffffc0200520:	8ff5                	and	a5,a5,a3
ffffffffc0200522:	8fcd                	or	a5,a5,a1
ffffffffc0200524:	0007859b          	sext.w	a1,a5
    if (magic != 0xd00dfeed) {
ffffffffc0200528:	d00e07b7          	lui	a5,0xd00e0
ffffffffc020052c:	eed78793          	addi	a5,a5,-275 # ffffffffd00dfeed <end+0xfed8a4d>
ffffffffc0200530:	10f59063          	bne	a1,a5,ffffffffc0200630 <dtb_init+0x1a2>
        return;
    }
    
    // 提取内存信息
    uint64_t mem_base, mem_size;
    if (extract_memory_info(dtb_vaddr, header, &mem_base, &mem_size) == 0) {
ffffffffc0200534:	461c                	lw	a5,8(a2)
ffffffffc0200536:	4658                	lw	a4,12(a2)
    int in_memory_node = 0;
ffffffffc0200538:	4b81                	li	s7,0
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc020053a:	0087d59b          	srliw	a1,a5,0x8
ffffffffc020053e:	0087541b          	srliw	s0,a4,0x8
ffffffffc0200542:	0187181b          	slliw	a6,a4,0x18
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200546:	0187531b          	srliw	t1,a4,0x18
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc020054a:	01879a1b          	slliw	s4,a5,0x18
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc020054e:	0187d89b          	srliw	a7,a5,0x18
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200552:	0104141b          	slliw	s0,s0,0x10
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200556:	0107571b          	srliw	a4,a4,0x10
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc020055a:	0105959b          	slliw	a1,a1,0x10
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc020055e:	0107d79b          	srliw	a5,a5,0x10
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200562:	8c69                	and	s0,s0,a0
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200564:	00686833          	or	a6,a6,t1
ffffffffc0200568:	0087171b          	slliw	a4,a4,0x8
ffffffffc020056c:	011a6a33          	or	s4,s4,a7
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200570:	8d6d                	and	a0,a0,a1
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200572:	0087979b          	slliw	a5,a5,0x8
ffffffffc0200576:	01046433          	or	s0,s0,a6
ffffffffc020057a:	8f75                	and	a4,a4,a3
ffffffffc020057c:	00aa6a33          	or	s4,s4,a0
ffffffffc0200580:	8ff5                	and	a5,a5,a3
ffffffffc0200582:	8c59                	or	s0,s0,a4
ffffffffc0200584:	00fa6a33          	or	s4,s4,a5
    const char *strings_base = (const char *)(dtb_vaddr + strings_offset);
ffffffffc0200588:	1402                	slli	s0,s0,0x20
    const uint32_t *struct_ptr = (const uint32_t *)(dtb_vaddr + struct_offset);
ffffffffc020058a:	1a02                	slli	s4,s4,0x20
    const char *strings_base = (const char *)(dtb_vaddr + strings_offset);
ffffffffc020058c:	9001                	srli	s0,s0,0x20
    const uint32_t *struct_ptr = (const uint32_t *)(dtb_vaddr + struct_offset);
ffffffffc020058e:	020a5a13          	srli	s4,s4,0x20
    const char *strings_base = (const char *)(dtb_vaddr + strings_offset);
ffffffffc0200592:	9432                	add	s0,s0,a2
    const uint32_t *struct_ptr = (const uint32_t *)(dtb_vaddr + struct_offset);
ffffffffc0200594:	9a32                	add	s4,s4,a2
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200596:	00ff0d37          	lui	s10,0xff0
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc020059a:	8c36                	mv	s8,a3
        switch (token) {
ffffffffc020059c:	4c8d                	li	s9,3
                if (in_memory_node && strcmp(prop_name, "reg") == 0 && prop_len >= 16) {
ffffffffc020059e:	00002917          	auipc	s2,0x2
ffffffffc02005a2:	d3a90913          	addi	s2,s2,-710 # ffffffffc02022d8 <commands+0xd0>
        switch (token) {
ffffffffc02005a6:	4991                	li	s3,4
ffffffffc02005a8:	4d85                	li	s11,1
                if (strncmp(name, "memory", 6) == 0) {
ffffffffc02005aa:	00002497          	auipc	s1,0x2
ffffffffc02005ae:	d2648493          	addi	s1,s1,-730 # ffffffffc02022d0 <commands+0xc8>
        uint32_t token = fdt32_to_cpu(*struct_ptr++);
ffffffffc02005b2:	000a2703          	lw	a4,0(s4)
ffffffffc02005b6:	004a0a93          	addi	s5,s4,4
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc02005ba:	0087579b          	srliw	a5,a4,0x8
ffffffffc02005be:	0187161b          	slliw	a2,a4,0x18
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc02005c2:	0187559b          	srliw	a1,a4,0x18
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc02005c6:	0107979b          	slliw	a5,a5,0x10
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc02005ca:	0107571b          	srliw	a4,a4,0x10
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc02005ce:	01a7f7b3          	and	a5,a5,s10
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc02005d2:	8e4d                	or	a2,a2,a1
ffffffffc02005d4:	0087171b          	slliw	a4,a4,0x8
ffffffffc02005d8:	8fd1                	or	a5,a5,a2
ffffffffc02005da:	01877733          	and	a4,a4,s8
ffffffffc02005de:	8fd9                	or	a5,a5,a4
ffffffffc02005e0:	2781                	sext.w	a5,a5
        switch (token) {
ffffffffc02005e2:	09978c63          	beq	a5,s9,ffffffffc020067a <dtb_init+0x1ec>
ffffffffc02005e6:	00fcea63          	bltu	s9,a5,ffffffffc02005fa <dtb_init+0x16c>
ffffffffc02005ea:	07b78663          	beq	a5,s11,ffffffffc0200656 <dtb_init+0x1c8>
ffffffffc02005ee:	4709                	li	a4,2
ffffffffc02005f0:	00e79763          	bne	a5,a4,ffffffffc02005fe <dtb_init+0x170>
ffffffffc02005f4:	4b81                	li	s7,0
ffffffffc02005f6:	8a56                	mv	s4,s5
ffffffffc02005f8:	bf6d                	j	ffffffffc02005b2 <dtb_init+0x124>
ffffffffc02005fa:	ff378ee3          	beq	a5,s3,ffffffffc02005f6 <dtb_init+0x168>
        cprintf("  End:  0x%016lx\n", mem_base + mem_size - 1);
        // 保存到全局变量，供 PMM 查询
        memory_base = mem_base;
        memory_size = mem_size;
    } else {
        cprintf("Warning: Could not extract memory info from DTB\n");
ffffffffc02005fe:	00002517          	auipc	a0,0x2
ffffffffc0200602:	d5250513          	addi	a0,a0,-686 # ffffffffc0202350 <commands+0x148>
ffffffffc0200606:	adbff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    }
    cprintf("DTB init completed\n");
ffffffffc020060a:	00002517          	auipc	a0,0x2
ffffffffc020060e:	d7e50513          	addi	a0,a0,-642 # ffffffffc0202388 <commands+0x180>
}
ffffffffc0200612:	7406                	ld	s0,96(sp)
ffffffffc0200614:	70a6                	ld	ra,104(sp)
ffffffffc0200616:	64e6                	ld	s1,88(sp)
ffffffffc0200618:	6946                	ld	s2,80(sp)
ffffffffc020061a:	69a6                	ld	s3,72(sp)
ffffffffc020061c:	6a06                	ld	s4,64(sp)
ffffffffc020061e:	7ae2                	ld	s5,56(sp)
ffffffffc0200620:	7b42                	ld	s6,48(sp)
ffffffffc0200622:	7ba2                	ld	s7,40(sp)
ffffffffc0200624:	7c02                	ld	s8,32(sp)
ffffffffc0200626:	6ce2                	ld	s9,24(sp)
ffffffffc0200628:	6d42                	ld	s10,16(sp)
ffffffffc020062a:	6da2                	ld	s11,8(sp)
ffffffffc020062c:	6165                	addi	sp,sp,112
    cprintf("DTB init completed\n");
ffffffffc020062e:	bc4d                	j	ffffffffc02000e0 <cprintf>
}
ffffffffc0200630:	7406                	ld	s0,96(sp)
ffffffffc0200632:	70a6                	ld	ra,104(sp)
ffffffffc0200634:	64e6                	ld	s1,88(sp)
ffffffffc0200636:	6946                	ld	s2,80(sp)
ffffffffc0200638:	69a6                	ld	s3,72(sp)
ffffffffc020063a:	6a06                	ld	s4,64(sp)
ffffffffc020063c:	7ae2                	ld	s5,56(sp)
ffffffffc020063e:	7b42                	ld	s6,48(sp)
ffffffffc0200640:	7ba2                	ld	s7,40(sp)
ffffffffc0200642:	7c02                	ld	s8,32(sp)
ffffffffc0200644:	6ce2                	ld	s9,24(sp)
ffffffffc0200646:	6d42                	ld	s10,16(sp)
ffffffffc0200648:	6da2                	ld	s11,8(sp)
        cprintf("Error: Invalid DTB magic number: 0x%x\n", magic);
ffffffffc020064a:	00002517          	auipc	a0,0x2
ffffffffc020064e:	c5e50513          	addi	a0,a0,-930 # ffffffffc02022a8 <commands+0xa0>
}
ffffffffc0200652:	6165                	addi	sp,sp,112
        cprintf("Error: Invalid DTB magic number: 0x%x\n", magic);
ffffffffc0200654:	b471                	j	ffffffffc02000e0 <cprintf>
                int name_len = strlen(name);
ffffffffc0200656:	8556                	mv	a0,s5
ffffffffc0200658:	388010ef          	jal	ra,ffffffffc02019e0 <strlen>
ffffffffc020065c:	8a2a                	mv	s4,a0
                if (strncmp(name, "memory", 6) == 0) {
ffffffffc020065e:	4619                	li	a2,6
ffffffffc0200660:	85a6                	mv	a1,s1
ffffffffc0200662:	8556                	mv	a0,s5
                int name_len = strlen(name);
ffffffffc0200664:	2a01                	sext.w	s4,s4
                if (strncmp(name, "memory", 6) == 0) {
ffffffffc0200666:	3ce010ef          	jal	ra,ffffffffc0201a34 <strncmp>
ffffffffc020066a:	e111                	bnez	a0,ffffffffc020066e <dtb_init+0x1e0>
                    in_memory_node = 1;
ffffffffc020066c:	4b85                	li	s7,1
                struct_ptr = (const uint32_t *)(((uintptr_t)struct_ptr + name_len + 4) & ~3);
ffffffffc020066e:	0a91                	addi	s5,s5,4
ffffffffc0200670:	9ad2                	add	s5,s5,s4
ffffffffc0200672:	ffcafa93          	andi	s5,s5,-4
        switch (token) {
ffffffffc0200676:	8a56                	mv	s4,s5
ffffffffc0200678:	bf2d                	j	ffffffffc02005b2 <dtb_init+0x124>
                uint32_t prop_len = fdt32_to_cpu(*struct_ptr++);
ffffffffc020067a:	004a2783          	lw	a5,4(s4)
                uint32_t prop_nameoff = fdt32_to_cpu(*struct_ptr++);
ffffffffc020067e:	00ca0a93          	addi	s5,s4,12
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200682:	0087db1b          	srliw	s6,a5,0x8
ffffffffc0200686:	0187971b          	slliw	a4,a5,0x18
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc020068a:	0187d61b          	srliw	a2,a5,0x18
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc020068e:	010b1b1b          	slliw	s6,s6,0x10
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc0200692:	0107d79b          	srliw	a5,a5,0x10
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc0200696:	01ab7b33          	and	s6,s6,s10
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc020069a:	8f51                	or	a4,a4,a2
ffffffffc020069c:	0087979b          	slliw	a5,a5,0x8
ffffffffc02006a0:	00eb6b33          	or	s6,s6,a4
ffffffffc02006a4:	0187f7b3          	and	a5,a5,s8
ffffffffc02006a8:	00fb6b33          	or	s6,s6,a5
ffffffffc02006ac:	2b01                	sext.w	s6,s6
                if (in_memory_node && strcmp(prop_name, "reg") == 0 && prop_len >= 16) {
ffffffffc02006ae:	000b9b63          	bnez	s7,ffffffffc02006c4 <dtb_init+0x236>
                struct_ptr = (const uint32_t *)(((uintptr_t)struct_ptr + prop_len + 3) & ~3);
ffffffffc02006b2:	1b02                	slli	s6,s6,0x20
ffffffffc02006b4:	0a8d                	addi	s5,s5,3
ffffffffc02006b6:	020b5b13          	srli	s6,s6,0x20
ffffffffc02006ba:	9ada                	add	s5,s5,s6
ffffffffc02006bc:	ffcafa93          	andi	s5,s5,-4
        switch (token) {
ffffffffc02006c0:	8a56                	mv	s4,s5
ffffffffc02006c2:	bdc5                	j	ffffffffc02005b2 <dtb_init+0x124>
                uint32_t prop_nameoff = fdt32_to_cpu(*struct_ptr++);
ffffffffc02006c4:	008a2783          	lw	a5,8(s4)
                if (in_memory_node && strcmp(prop_name, "reg") == 0 && prop_len >= 16) {
ffffffffc02006c8:	85ca                	mv	a1,s2
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc02006ca:	0087d71b          	srliw	a4,a5,0x8
ffffffffc02006ce:	0187951b          	slliw	a0,a5,0x18
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc02006d2:	0187d61b          	srliw	a2,a5,0x18
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc02006d6:	0107171b          	slliw	a4,a4,0x10
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc02006da:	0107d79b          	srliw	a5,a5,0x10
ffffffffc02006de:	8d51                	or	a0,a0,a2
    return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | 
ffffffffc02006e0:	01a77733          	and	a4,a4,s10
           (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff);
ffffffffc02006e4:	0087979b          	slliw	a5,a5,0x8
ffffffffc02006e8:	8d59                	or	a0,a0,a4
ffffffffc02006ea:	0187f7b3          	and	a5,a5,s8
ffffffffc02006ee:	8fc9                	or	a5,a5,a0
                const char *prop_name = strings_base + prop_nameoff;
ffffffffc02006f0:	02079513          	slli	a0,a5,0x20
ffffffffc02006f4:	9101                	srli	a0,a0,0x20
                if (in_memory_node && strcmp(prop_name, "reg") == 0 && prop_len >= 16) {
ffffffffc02006f6:	9522                	add	a0,a0,s0
ffffffffc02006f8:	31e010ef          	jal	ra,ffffffffc0201a16 <strcmp>
ffffffffc02006fc:	f95d                	bnez	a0,ffffffffc02006b2 <dtb_init+0x224>
ffffffffc02006fe:	47bd                	li	a5,15
ffffffffc0200700:	fb67f9e3          	bgeu	a5,s6,ffffffffc02006b2 <dtb_init+0x224>
                    *mem_base = fdt64_to_cpu(reg_data[0]);
ffffffffc0200704:	00ca3503          	ld	a0,12(s4)
ffffffffc0200708:	d29ff0ef          	jal	ra,ffffffffc0200430 <fdt64_to_cpu>
ffffffffc020070c:	84aa                	mv	s1,a0
                    *mem_size = fdt64_to_cpu(reg_data[1]);
ffffffffc020070e:	014a3503          	ld	a0,20(s4)
ffffffffc0200712:	d1fff0ef          	jal	ra,ffffffffc0200430 <fdt64_to_cpu>
ffffffffc0200716:	842a                	mv	s0,a0
        cprintf("Physical Memory from DTB:\n");
ffffffffc0200718:	00002517          	auipc	a0,0x2
ffffffffc020071c:	bc850513          	addi	a0,a0,-1080 # ffffffffc02022e0 <commands+0xd8>
ffffffffc0200720:	9c1ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
        cprintf("  Base: 0x%016lx\n", mem_base);
ffffffffc0200724:	85a6                	mv	a1,s1
ffffffffc0200726:	00002517          	auipc	a0,0x2
ffffffffc020072a:	bda50513          	addi	a0,a0,-1062 # ffffffffc0202300 <commands+0xf8>
ffffffffc020072e:	9b3ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
        cprintf("  Size: 0x%016lx (%ld MB)\n", mem_size, mem_size / (1024 * 1024));
ffffffffc0200732:	01445613          	srli	a2,s0,0x14
ffffffffc0200736:	85a2                	mv	a1,s0
ffffffffc0200738:	00002517          	auipc	a0,0x2
ffffffffc020073c:	be050513          	addi	a0,a0,-1056 # ffffffffc0202318 <commands+0x110>
ffffffffc0200740:	9a1ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
        cprintf("  End:  0x%016lx\n", mem_base + mem_size - 1);
ffffffffc0200744:	008485b3          	add	a1,s1,s0
ffffffffc0200748:	15fd                	addi	a1,a1,-1
ffffffffc020074a:	00002517          	auipc	a0,0x2
ffffffffc020074e:	bee50513          	addi	a0,a0,-1042 # ffffffffc0202338 <commands+0x130>
ffffffffc0200752:	98fff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("DTB init completed\n");
ffffffffc0200756:	00002517          	auipc	a0,0x2
ffffffffc020075a:	c3250513          	addi	a0,a0,-974 # ffffffffc0202388 <commands+0x180>
        memory_base = mem_base;
ffffffffc020075e:	00007797          	auipc	a5,0x7
ffffffffc0200762:	ce97b523          	sd	s1,-790(a5) # ffffffffc0207448 <memory_base>
        memory_size = mem_size;
ffffffffc0200766:	00007797          	auipc	a5,0x7
ffffffffc020076a:	ce87b523          	sd	s0,-790(a5) # ffffffffc0207450 <memory_size>
    cprintf("DTB init completed\n");
ffffffffc020076e:	b555                	j	ffffffffc0200612 <dtb_init+0x184>

ffffffffc0200770 <get_memory_base>:

uint64_t get_memory_base(void) {
    return memory_base;
}
ffffffffc0200770:	00007517          	auipc	a0,0x7
ffffffffc0200774:	cd853503          	ld	a0,-808(a0) # ffffffffc0207448 <memory_base>
ffffffffc0200778:	8082                	ret

ffffffffc020077a <get_memory_size>:

uint64_t get_memory_size(void) {
    return memory_size;
}
ffffffffc020077a:	00007517          	auipc	a0,0x7
ffffffffc020077e:	cd653503          	ld	a0,-810(a0) # ffffffffc0207450 <memory_size>
ffffffffc0200782:	8082                	ret

ffffffffc0200784 <clock_init>:

/* *
 * clock_init - initialize 8253 clock to interrupt 100 times per second,
 * and then enable IRQ_TIMER.
 * */
void clock_init(void) {
ffffffffc0200784:	1141                	addi	sp,sp,-16
ffffffffc0200786:	e406                	sd	ra,8(sp)
    // enable timer interrupt in sie
    set_csr(sie, MIP_STIP);
ffffffffc0200788:	02000793          	li	a5,32
ffffffffc020078c:	1047a7f3          	csrrs	a5,sie,a5
    __asm__ __volatile__("rdtime %0" : "=r"(n));
ffffffffc0200790:	c0102573          	rdtime	a0
    ticks = 0;

    cprintf("++ setup timer interrupts\n");
}

void clock_set_next_event(void) { sbi_set_timer(get_cycles() + timebase); }
ffffffffc0200794:	67e1                	lui	a5,0x18
ffffffffc0200796:	6a078793          	addi	a5,a5,1696 # 186a0 <kern_entry-0xffffffffc01e7960>
ffffffffc020079a:	953e                	add	a0,a0,a5
ffffffffc020079c:	7a2010ef          	jal	ra,ffffffffc0201f3e <sbi_set_timer>
}
ffffffffc02007a0:	60a2                	ld	ra,8(sp)
    ticks = 0;
ffffffffc02007a2:	00007797          	auipc	a5,0x7
ffffffffc02007a6:	cc07bb23          	sd	zero,-810(a5) # ffffffffc0207478 <ticks>
    cprintf("++ setup timer interrupts\n");
ffffffffc02007aa:	00002517          	auipc	a0,0x2
ffffffffc02007ae:	bf650513          	addi	a0,a0,-1034 # ffffffffc02023a0 <commands+0x198>
}
ffffffffc02007b2:	0141                	addi	sp,sp,16
    cprintf("++ setup timer interrupts\n");
ffffffffc02007b4:	b235                	j	ffffffffc02000e0 <cprintf>

ffffffffc02007b6 <clock_set_next_event>:
    __asm__ __volatile__("rdtime %0" : "=r"(n));
ffffffffc02007b6:	c0102573          	rdtime	a0
void clock_set_next_event(void) { sbi_set_timer(get_cycles() + timebase); }
ffffffffc02007ba:	67e1                	lui	a5,0x18
ffffffffc02007bc:	6a078793          	addi	a5,a5,1696 # 186a0 <kern_entry-0xffffffffc01e7960>
ffffffffc02007c0:	953e                	add	a0,a0,a5
ffffffffc02007c2:	77c0106f          	j	ffffffffc0201f3e <sbi_set_timer>

ffffffffc02007c6 <cons_init>:

/* serial_intr - try to feed input characters from serial port */
void serial_intr(void) {}

/* cons_init - initializes the console devices */
void cons_init(void) {}
ffffffffc02007c6:	8082                	ret

ffffffffc02007c8 <cons_putc>:

/* cons_putc - print a single character @c to console devices */
void cons_putc(int c) { sbi_console_putchar((unsigned char)c); }
ffffffffc02007c8:	0ff57513          	andi	a0,a0,255
ffffffffc02007cc:	7580106f          	j	ffffffffc0201f24 <sbi_console_putchar>

ffffffffc02007d0 <cons_getc>:
 * cons_getc - return the next input character from console,
 * or 0 if none waiting.
 * */
int cons_getc(void) {
    int c = 0;
    c = sbi_console_getchar();
ffffffffc02007d0:	7880106f          	j	ffffffffc0201f58 <sbi_console_getchar>

ffffffffc02007d4 <intr_enable>:
#include <intr.h>
#include <riscv.h>

/* intr_enable - enable irq interrupt */
void intr_enable(void) { set_csr(sstatus, SSTATUS_SIE); }
ffffffffc02007d4:	100167f3          	csrrsi	a5,sstatus,2
ffffffffc02007d8:	8082                	ret

ffffffffc02007da <intr_disable>:

/* intr_disable - disable irq interrupt */
void intr_disable(void) { clear_csr(sstatus, SSTATUS_SIE); }
ffffffffc02007da:	100177f3          	csrrci	a5,sstatus,2
ffffffffc02007de:	8082                	ret

ffffffffc02007e0 <idt_init>:
     */

    extern void __alltraps(void);
    /* Set sup0 scratch register to 0, indicating to exception vector
       that we are presently executing in the kernel */
    write_csr(sscratch, 0);
ffffffffc02007e0:	14005073          	csrwi	sscratch,0
    /* Set the exception vector address */
    write_csr(stvec, &__alltraps);
ffffffffc02007e4:	00000797          	auipc	a5,0x0
ffffffffc02007e8:	3d078793          	addi	a5,a5,976 # ffffffffc0200bb4 <__alltraps>
ffffffffc02007ec:	10579073          	csrw	stvec,a5
}
ffffffffc02007f0:	8082                	ret

ffffffffc02007f2 <print_regs>:
    cprintf("  badvaddr 0x%08x\n", tf->badvaddr);
    cprintf("  cause    0x%08x\n", tf->cause);
}

void print_regs(struct pushregs *gpr) {
    cprintf("  zero     0x%08x\n", gpr->zero);
ffffffffc02007f2:	610c                	ld	a1,0(a0)
void print_regs(struct pushregs *gpr) {
ffffffffc02007f4:	1141                	addi	sp,sp,-16
ffffffffc02007f6:	e022                	sd	s0,0(sp)
ffffffffc02007f8:	842a                	mv	s0,a0
    cprintf("  zero     0x%08x\n", gpr->zero);
ffffffffc02007fa:	00002517          	auipc	a0,0x2
ffffffffc02007fe:	bc650513          	addi	a0,a0,-1082 # ffffffffc02023c0 <commands+0x1b8>
void print_regs(struct pushregs *gpr) {
ffffffffc0200802:	e406                	sd	ra,8(sp)
    cprintf("  zero     0x%08x\n", gpr->zero);
ffffffffc0200804:	8ddff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  ra       0x%08x\n", gpr->ra);
ffffffffc0200808:	640c                	ld	a1,8(s0)
ffffffffc020080a:	00002517          	auipc	a0,0x2
ffffffffc020080e:	bce50513          	addi	a0,a0,-1074 # ffffffffc02023d8 <commands+0x1d0>
ffffffffc0200812:	8cfff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  sp       0x%08x\n", gpr->sp);
ffffffffc0200816:	680c                	ld	a1,16(s0)
ffffffffc0200818:	00002517          	auipc	a0,0x2
ffffffffc020081c:	bd850513          	addi	a0,a0,-1064 # ffffffffc02023f0 <commands+0x1e8>
ffffffffc0200820:	8c1ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  gp       0x%08x\n", gpr->gp);
ffffffffc0200824:	6c0c                	ld	a1,24(s0)
ffffffffc0200826:	00002517          	auipc	a0,0x2
ffffffffc020082a:	be250513          	addi	a0,a0,-1054 # ffffffffc0202408 <commands+0x200>
ffffffffc020082e:	8b3ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  tp       0x%08x\n", gpr->tp);
ffffffffc0200832:	700c                	ld	a1,32(s0)
ffffffffc0200834:	00002517          	auipc	a0,0x2
ffffffffc0200838:	bec50513          	addi	a0,a0,-1044 # ffffffffc0202420 <commands+0x218>
ffffffffc020083c:	8a5ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  t0       0x%08x\n", gpr->t0);
ffffffffc0200840:	740c                	ld	a1,40(s0)
ffffffffc0200842:	00002517          	auipc	a0,0x2
ffffffffc0200846:	bf650513          	addi	a0,a0,-1034 # ffffffffc0202438 <commands+0x230>
ffffffffc020084a:	897ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  t1       0x%08x\n", gpr->t1);
ffffffffc020084e:	780c                	ld	a1,48(s0)
ffffffffc0200850:	00002517          	auipc	a0,0x2
ffffffffc0200854:	c0050513          	addi	a0,a0,-1024 # ffffffffc0202450 <commands+0x248>
ffffffffc0200858:	889ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  t2       0x%08x\n", gpr->t2);
ffffffffc020085c:	7c0c                	ld	a1,56(s0)
ffffffffc020085e:	00002517          	auipc	a0,0x2
ffffffffc0200862:	c0a50513          	addi	a0,a0,-1014 # ffffffffc0202468 <commands+0x260>
ffffffffc0200866:	87bff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  s0       0x%08x\n", gpr->s0);
ffffffffc020086a:	602c                	ld	a1,64(s0)
ffffffffc020086c:	00002517          	auipc	a0,0x2
ffffffffc0200870:	c1450513          	addi	a0,a0,-1004 # ffffffffc0202480 <commands+0x278>
ffffffffc0200874:	86dff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  s1       0x%08x\n", gpr->s1);
ffffffffc0200878:	642c                	ld	a1,72(s0)
ffffffffc020087a:	00002517          	auipc	a0,0x2
ffffffffc020087e:	c1e50513          	addi	a0,a0,-994 # ffffffffc0202498 <commands+0x290>
ffffffffc0200882:	85fff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  a0       0x%08x\n", gpr->a0);
ffffffffc0200886:	682c                	ld	a1,80(s0)
ffffffffc0200888:	00002517          	auipc	a0,0x2
ffffffffc020088c:	c2850513          	addi	a0,a0,-984 # ffffffffc02024b0 <commands+0x2a8>
ffffffffc0200890:	851ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  a1       0x%08x\n", gpr->a1);
ffffffffc0200894:	6c2c                	ld	a1,88(s0)
ffffffffc0200896:	00002517          	auipc	a0,0x2
ffffffffc020089a:	c3250513          	addi	a0,a0,-974 # ffffffffc02024c8 <commands+0x2c0>
ffffffffc020089e:	843ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  a2       0x%08x\n", gpr->a2);
ffffffffc02008a2:	702c                	ld	a1,96(s0)
ffffffffc02008a4:	00002517          	auipc	a0,0x2
ffffffffc02008a8:	c3c50513          	addi	a0,a0,-964 # ffffffffc02024e0 <commands+0x2d8>
ffffffffc02008ac:	835ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  a3       0x%08x\n", gpr->a3);
ffffffffc02008b0:	742c                	ld	a1,104(s0)
ffffffffc02008b2:	00002517          	auipc	a0,0x2
ffffffffc02008b6:	c4650513          	addi	a0,a0,-954 # ffffffffc02024f8 <commands+0x2f0>
ffffffffc02008ba:	827ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  a4       0x%08x\n", gpr->a4);
ffffffffc02008be:	782c                	ld	a1,112(s0)
ffffffffc02008c0:	00002517          	auipc	a0,0x2
ffffffffc02008c4:	c5050513          	addi	a0,a0,-944 # ffffffffc0202510 <commands+0x308>
ffffffffc02008c8:	819ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  a5       0x%08x\n", gpr->a5);
ffffffffc02008cc:	7c2c                	ld	a1,120(s0)
ffffffffc02008ce:	00002517          	auipc	a0,0x2
ffffffffc02008d2:	c5a50513          	addi	a0,a0,-934 # ffffffffc0202528 <commands+0x320>
ffffffffc02008d6:	80bff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  a6       0x%08x\n", gpr->a6);
ffffffffc02008da:	604c                	ld	a1,128(s0)
ffffffffc02008dc:	00002517          	auipc	a0,0x2
ffffffffc02008e0:	c6450513          	addi	a0,a0,-924 # ffffffffc0202540 <commands+0x338>
ffffffffc02008e4:	ffcff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  a7       0x%08x\n", gpr->a7);
ffffffffc02008e8:	644c                	ld	a1,136(s0)
ffffffffc02008ea:	00002517          	auipc	a0,0x2
ffffffffc02008ee:	c6e50513          	addi	a0,a0,-914 # ffffffffc0202558 <commands+0x350>
ffffffffc02008f2:	feeff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  s2       0x%08x\n", gpr->s2);
ffffffffc02008f6:	684c                	ld	a1,144(s0)
ffffffffc02008f8:	00002517          	auipc	a0,0x2
ffffffffc02008fc:	c7850513          	addi	a0,a0,-904 # ffffffffc0202570 <commands+0x368>
ffffffffc0200900:	fe0ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  s3       0x%08x\n", gpr->s3);
ffffffffc0200904:	6c4c                	ld	a1,152(s0)
ffffffffc0200906:	00002517          	auipc	a0,0x2
ffffffffc020090a:	c8250513          	addi	a0,a0,-894 # ffffffffc0202588 <commands+0x380>
ffffffffc020090e:	fd2ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  s4       0x%08x\n", gpr->s4);
ffffffffc0200912:	704c                	ld	a1,160(s0)
ffffffffc0200914:	00002517          	auipc	a0,0x2
ffffffffc0200918:	c8c50513          	addi	a0,a0,-884 # ffffffffc02025a0 <commands+0x398>
ffffffffc020091c:	fc4ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  s5       0x%08x\n", gpr->s5);
ffffffffc0200920:	744c                	ld	a1,168(s0)
ffffffffc0200922:	00002517          	auipc	a0,0x2
ffffffffc0200926:	c9650513          	addi	a0,a0,-874 # ffffffffc02025b8 <commands+0x3b0>
ffffffffc020092a:	fb6ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  s6       0x%08x\n", gpr->s6);
ffffffffc020092e:	784c                	ld	a1,176(s0)
ffffffffc0200930:	00002517          	auipc	a0,0x2
ffffffffc0200934:	ca050513          	addi	a0,a0,-864 # ffffffffc02025d0 <commands+0x3c8>
ffffffffc0200938:	fa8ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  s7       0x%08x\n", gpr->s7);
ffffffffc020093c:	7c4c                	ld	a1,184(s0)
ffffffffc020093e:	00002517          	auipc	a0,0x2
ffffffffc0200942:	caa50513          	addi	a0,a0,-854 # ffffffffc02025e8 <commands+0x3e0>
ffffffffc0200946:	f9aff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  s8       0x%08x\n", gpr->s8);
ffffffffc020094a:	606c                	ld	a1,192(s0)
ffffffffc020094c:	00002517          	auipc	a0,0x2
ffffffffc0200950:	cb450513          	addi	a0,a0,-844 # ffffffffc0202600 <commands+0x3f8>
ffffffffc0200954:	f8cff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  s9       0x%08x\n", gpr->s9);
ffffffffc0200958:	646c                	ld	a1,200(s0)
ffffffffc020095a:	00002517          	auipc	a0,0x2
ffffffffc020095e:	cbe50513          	addi	a0,a0,-834 # ffffffffc0202618 <commands+0x410>
ffffffffc0200962:	f7eff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  s10      0x%08x\n", gpr->s10);
ffffffffc0200966:	686c                	ld	a1,208(s0)
ffffffffc0200968:	00002517          	auipc	a0,0x2
ffffffffc020096c:	cc850513          	addi	a0,a0,-824 # ffffffffc0202630 <commands+0x428>
ffffffffc0200970:	f70ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  s11      0x%08x\n", gpr->s11);
ffffffffc0200974:	6c6c                	ld	a1,216(s0)
ffffffffc0200976:	00002517          	auipc	a0,0x2
ffffffffc020097a:	cd250513          	addi	a0,a0,-814 # ffffffffc0202648 <commands+0x440>
ffffffffc020097e:	f62ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  t3       0x%08x\n", gpr->t3);
ffffffffc0200982:	706c                	ld	a1,224(s0)
ffffffffc0200984:	00002517          	auipc	a0,0x2
ffffffffc0200988:	cdc50513          	addi	a0,a0,-804 # ffffffffc0202660 <commands+0x458>
ffffffffc020098c:	f54ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  t4       0x%08x\n", gpr->t4);
ffffffffc0200990:	746c                	ld	a1,232(s0)
ffffffffc0200992:	00002517          	auipc	a0,0x2
ffffffffc0200996:	ce650513          	addi	a0,a0,-794 # ffffffffc0202678 <commands+0x470>
ffffffffc020099a:	f46ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  t5       0x%08x\n", gpr->t5);
ffffffffc020099e:	786c                	ld	a1,240(s0)
ffffffffc02009a0:	00002517          	auipc	a0,0x2
ffffffffc02009a4:	cf050513          	addi	a0,a0,-784 # ffffffffc0202690 <commands+0x488>
ffffffffc02009a8:	f38ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  t6       0x%08x\n", gpr->t6);
ffffffffc02009ac:	7c6c                	ld	a1,248(s0)
}
ffffffffc02009ae:	6402                	ld	s0,0(sp)
ffffffffc02009b0:	60a2                	ld	ra,8(sp)
    cprintf("  t6       0x%08x\n", gpr->t6);
ffffffffc02009b2:	00002517          	auipc	a0,0x2
ffffffffc02009b6:	cf650513          	addi	a0,a0,-778 # ffffffffc02026a8 <commands+0x4a0>
}
ffffffffc02009ba:	0141                	addi	sp,sp,16
    cprintf("  t6       0x%08x\n", gpr->t6);
ffffffffc02009bc:	f24ff06f          	j	ffffffffc02000e0 <cprintf>

ffffffffc02009c0 <print_trapframe>:
void print_trapframe(struct trapframe *tf) {
ffffffffc02009c0:	1141                	addi	sp,sp,-16
ffffffffc02009c2:	e022                	sd	s0,0(sp)
    cprintf("trapframe at %p\n", tf);
ffffffffc02009c4:	85aa                	mv	a1,a0
void print_trapframe(struct trapframe *tf) {
ffffffffc02009c6:	842a                	mv	s0,a0
    cprintf("trapframe at %p\n", tf);
ffffffffc02009c8:	00002517          	auipc	a0,0x2
ffffffffc02009cc:	cf850513          	addi	a0,a0,-776 # ffffffffc02026c0 <commands+0x4b8>
void print_trapframe(struct trapframe *tf) {
ffffffffc02009d0:	e406                	sd	ra,8(sp)
    cprintf("trapframe at %p\n", tf);
ffffffffc02009d2:	f0eff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    print_regs(&tf->gpr);
ffffffffc02009d6:	8522                	mv	a0,s0
ffffffffc02009d8:	e1bff0ef          	jal	ra,ffffffffc02007f2 <print_regs>
    cprintf("  status   0x%08x\n", tf->status);
ffffffffc02009dc:	10043583          	ld	a1,256(s0)
ffffffffc02009e0:	00002517          	auipc	a0,0x2
ffffffffc02009e4:	cf850513          	addi	a0,a0,-776 # ffffffffc02026d8 <commands+0x4d0>
ffffffffc02009e8:	ef8ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  epc      0x%08x\n", tf->epc);
ffffffffc02009ec:	10843583          	ld	a1,264(s0)
ffffffffc02009f0:	00002517          	auipc	a0,0x2
ffffffffc02009f4:	d0050513          	addi	a0,a0,-768 # ffffffffc02026f0 <commands+0x4e8>
ffffffffc02009f8:	ee8ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  badvaddr 0x%08x\n", tf->badvaddr);
ffffffffc02009fc:	11043583          	ld	a1,272(s0)
ffffffffc0200a00:	00002517          	auipc	a0,0x2
ffffffffc0200a04:	d0850513          	addi	a0,a0,-760 # ffffffffc0202708 <commands+0x500>
ffffffffc0200a08:	ed8ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    cprintf("  cause    0x%08x\n", tf->cause);
ffffffffc0200a0c:	11843583          	ld	a1,280(s0)
}
ffffffffc0200a10:	6402                	ld	s0,0(sp)
ffffffffc0200a12:	60a2                	ld	ra,8(sp)
    cprintf("  cause    0x%08x\n", tf->cause);
ffffffffc0200a14:	00002517          	auipc	a0,0x2
ffffffffc0200a18:	d0c50513          	addi	a0,a0,-756 # ffffffffc0202720 <commands+0x518>
}
ffffffffc0200a1c:	0141                	addi	sp,sp,16
    cprintf("  cause    0x%08x\n", tf->cause);
ffffffffc0200a1e:	ec2ff06f          	j	ffffffffc02000e0 <cprintf>

ffffffffc0200a22 <interrupt_handler>:

void interrupt_handler(struct trapframe *tf) {
    intptr_t cause = (tf->cause << 1) >> 1;
ffffffffc0200a22:	11853783          	ld	a5,280(a0)
ffffffffc0200a26:	472d                	li	a4,11
ffffffffc0200a28:	0786                	slli	a5,a5,0x1
ffffffffc0200a2a:	8385                	srli	a5,a5,0x1
ffffffffc0200a2c:	08f76363          	bltu	a4,a5,ffffffffc0200ab2 <interrupt_handler+0x90>
ffffffffc0200a30:	00002717          	auipc	a4,0x2
ffffffffc0200a34:	dd070713          	addi	a4,a4,-560 # ffffffffc0202800 <commands+0x5f8>
ffffffffc0200a38:	078a                	slli	a5,a5,0x2
ffffffffc0200a3a:	97ba                	add	a5,a5,a4
ffffffffc0200a3c:	439c                	lw	a5,0(a5)
ffffffffc0200a3e:	97ba                	add	a5,a5,a4
ffffffffc0200a40:	8782                	jr	a5
            break;
        case IRQ_H_SOFT:
            cprintf("Hypervisor software interrupt\n");
            break;
        case IRQ_M_SOFT:
            cprintf("Machine software interrupt\n");
ffffffffc0200a42:	00002517          	auipc	a0,0x2
ffffffffc0200a46:	d5650513          	addi	a0,a0,-682 # ffffffffc0202798 <commands+0x590>
ffffffffc0200a4a:	e96ff06f          	j	ffffffffc02000e0 <cprintf>
            cprintf("Hypervisor software interrupt\n");
ffffffffc0200a4e:	00002517          	auipc	a0,0x2
ffffffffc0200a52:	d2a50513          	addi	a0,a0,-726 # ffffffffc0202778 <commands+0x570>
ffffffffc0200a56:	e8aff06f          	j	ffffffffc02000e0 <cprintf>
            cprintf("User software interrupt\n");
ffffffffc0200a5a:	00002517          	auipc	a0,0x2
ffffffffc0200a5e:	cde50513          	addi	a0,a0,-802 # ffffffffc0202738 <commands+0x530>
ffffffffc0200a62:	e7eff06f          	j	ffffffffc02000e0 <cprintf>
            break;
        case IRQ_U_TIMER:
            cprintf("User Timer interrupt\n");
ffffffffc0200a66:	00002517          	auipc	a0,0x2
ffffffffc0200a6a:	d5250513          	addi	a0,a0,-686 # ffffffffc02027b8 <commands+0x5b0>
ffffffffc0200a6e:	e72ff06f          	j	ffffffffc02000e0 <cprintf>
void interrupt_handler(struct trapframe *tf) {
ffffffffc0200a72:	1141                	addi	sp,sp,-16
ffffffffc0200a74:	e406                	sd	ra,8(sp)
             *(3)当计数器加到100的时候，我们会输出一个`100ticks`表示我们触发了100次时钟中断，同时打印次数（num）加一
            * (4)判断打印次数，当打印次数为10时，调用<sbi.h>中的关机函数关机
            */

            // ★  时钟中断处理实现
            clock_set_next_event();     // (1) 预约下一次时钟中断（并清除 STIP）
ffffffffc0200a76:	d41ff0ef          	jal	ra,ffffffffc02007b6 <clock_set_next_event>
            ticks++;                    // (2) 使用 clock.c 的全局 ticks：+1
ffffffffc0200a7a:	00007797          	auipc	a5,0x7
ffffffffc0200a7e:	9fe78793          	addi	a5,a5,-1538 # ffffffffc0207478 <ticks>
ffffffffc0200a82:	6398                	ld	a4,0(a5)
ffffffffc0200a84:	0705                	addi	a4,a4,1
ffffffffc0200a86:	e398                	sd	a4,0(a5)
            if (ticks % TICK_NUM == 0) {    // (3) 每 100 次打印一次
ffffffffc0200a88:	639c                	ld	a5,0(a5)
ffffffffc0200a8a:	06400713          	li	a4,100
ffffffffc0200a8e:	02e7f7b3          	remu	a5,a5,a4
ffffffffc0200a92:	c38d                	beqz	a5,ffffffffc0200ab4 <interrupt_handler+0x92>
            break;
        default:
            print_trapframe(tf);
            break;
    }
}
ffffffffc0200a94:	60a2                	ld	ra,8(sp)
ffffffffc0200a96:	0141                	addi	sp,sp,16
ffffffffc0200a98:	8082                	ret
            cprintf("Supervisor external interrupt\n");
ffffffffc0200a9a:	00002517          	auipc	a0,0x2
ffffffffc0200a9e:	d4650513          	addi	a0,a0,-698 # ffffffffc02027e0 <commands+0x5d8>
ffffffffc0200aa2:	e3eff06f          	j	ffffffffc02000e0 <cprintf>
            cprintf("Supervisor software interrupt\n");
ffffffffc0200aa6:	00002517          	auipc	a0,0x2
ffffffffc0200aaa:	cb250513          	addi	a0,a0,-846 # ffffffffc0202758 <commands+0x550>
ffffffffc0200aae:	e32ff06f          	j	ffffffffc02000e0 <cprintf>
            print_trapframe(tf);
ffffffffc0200ab2:	b739                	j	ffffffffc02009c0 <print_trapframe>
    cprintf("%d ticks\n", TICK_NUM);
ffffffffc0200ab4:	06400593          	li	a1,100
ffffffffc0200ab8:	00002517          	auipc	a0,0x2
ffffffffc0200abc:	d1850513          	addi	a0,a0,-744 # ffffffffc02027d0 <commands+0x5c8>
ffffffffc0200ac0:	e20ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
                print_num++;                // 已打印“100 ticks”的行数 +1
ffffffffc0200ac4:	00007797          	auipc	a5,0x7
ffffffffc0200ac8:	9947a783          	lw	a5,-1644(a5) # ffffffffc0207458 <print_num>
ffffffffc0200acc:	00007717          	auipc	a4,0x7
ffffffffc0200ad0:	98c70713          	addi	a4,a4,-1652 # ffffffffc0207458 <print_num>
ffffffffc0200ad4:	2785                	addiw	a5,a5,1
ffffffffc0200ad6:	c31c                	sw	a5,0(a4)
                if (print_num >= 10) {      // (4) 打印满 10 行后关机
ffffffffc0200ad8:	431c                	lw	a5,0(a4)
ffffffffc0200ada:	4725                	li	a4,9
ffffffffc0200adc:	2781                	sext.w	a5,a5
ffffffffc0200ade:	faf77be3          	bgeu	a4,a5,ffffffffc0200a94 <interrupt_handler+0x72>
}
ffffffffc0200ae2:	60a2                	ld	ra,8(sp)
ffffffffc0200ae4:	0141                	addi	sp,sp,16
                    sbi_shutdown();         //  通过 SBI 关机
ffffffffc0200ae6:	48e0106f          	j	ffffffffc0201f74 <sbi_shutdown>

ffffffffc0200aea <exception_handler>:

void exception_handler(struct trapframe *tf) {
ffffffffc0200aea:	7179                	addi	sp,sp,-48
ffffffffc0200aec:	f022                	sd	s0,32(sp)
    switch (tf->cause) {
ffffffffc0200aee:	11853403          	ld	s0,280(a0)
void exception_handler(struct trapframe *tf) {
ffffffffc0200af2:	ec26                	sd	s1,24(sp)
ffffffffc0200af4:	e84a                	sd	s2,16(sp)
ffffffffc0200af6:	f406                	sd	ra,40(sp)
ffffffffc0200af8:	e44e                	sd	s3,8(sp)
    switch (tf->cause) {
ffffffffc0200afa:	490d                	li	s2,3
void exception_handler(struct trapframe *tf) {
ffffffffc0200afc:	84aa                	mv	s1,a0
    switch (tf->cause) {
ffffffffc0200afe:	07240163          	beq	s0,s2,ffffffffc0200b60 <exception_handler+0x76>
ffffffffc0200b02:	04896463          	bltu	s2,s0,ffffffffc0200b4a <exception_handler+0x60>
ffffffffc0200b06:	4789                	li	a5,2
ffffffffc0200b08:	02f41a63          	bne	s0,a5,ffffffffc0200b3c <exception_handler+0x52>
             *(2)输出异常指令地址
             *(3)更新 tf->epc寄存器
            */
            // ★ 非法指令异常——输出类型与地址，并前进 EPC
            {
                uintptr_t epc = tf->epc;
ffffffffc0200b0c:	10853983          	ld	s3,264(a0)
                cprintf("Illegal instruction caught at 0x%08x\n", (unsigned int)epc);
ffffffffc0200b10:	00002517          	auipc	a0,0x2
ffffffffc0200b14:	d2050513          	addi	a0,a0,-736 # ffffffffc0202830 <commands+0x628>
ffffffffc0200b18:	0009859b          	sext.w	a1,s3
ffffffffc0200b1c:	dc4ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
                cprintf("Exception type:Illegal instruction\n");
ffffffffc0200b20:	00002517          	auipc	a0,0x2
ffffffffc0200b24:	d3850513          	addi	a0,a0,-712 # ffffffffc0202858 <commands+0x650>
ffffffffc0200b28:	db8ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    unsigned short half = *p;
ffffffffc0200b2c:	0009d783          	lhu	a5,0(s3)
    return ((half & 0x3) == 0x3) ? 4 : 2;
ffffffffc0200b30:	8b8d                	andi	a5,a5,3
ffffffffc0200b32:	07278863          	beq	a5,s2,ffffffffc0200ba2 <exception_handler+0xb8>
                tf->epc = epc + rv_insn_len(epc);
ffffffffc0200b36:	944e                	add	s0,s0,s3
ffffffffc0200b38:	1084b423          	sd	s0,264(s1)
            break;
        default:
            print_trapframe(tf);
            break;
    }
}
ffffffffc0200b3c:	70a2                	ld	ra,40(sp)
ffffffffc0200b3e:	7402                	ld	s0,32(sp)
ffffffffc0200b40:	64e2                	ld	s1,24(sp)
ffffffffc0200b42:	6942                	ld	s2,16(sp)
ffffffffc0200b44:	69a2                	ld	s3,8(sp)
ffffffffc0200b46:	6145                	addi	sp,sp,48
ffffffffc0200b48:	8082                	ret
    switch (tf->cause) {
ffffffffc0200b4a:	1471                	addi	s0,s0,-4
ffffffffc0200b4c:	479d                	li	a5,7
ffffffffc0200b4e:	fe87f7e3          	bgeu	a5,s0,ffffffffc0200b3c <exception_handler+0x52>
}
ffffffffc0200b52:	7402                	ld	s0,32(sp)
ffffffffc0200b54:	70a2                	ld	ra,40(sp)
ffffffffc0200b56:	64e2                	ld	s1,24(sp)
ffffffffc0200b58:	6942                	ld	s2,16(sp)
ffffffffc0200b5a:	69a2                	ld	s3,8(sp)
ffffffffc0200b5c:	6145                	addi	sp,sp,48
            print_trapframe(tf);
ffffffffc0200b5e:	b58d                	j	ffffffffc02009c0 <print_trapframe>
                uintptr_t epc = tf->epc;
ffffffffc0200b60:	10853903          	ld	s2,264(a0)
                cprintf("ebreak caught at 0x%08x\n", (unsigned int)epc);
ffffffffc0200b64:	00002517          	auipc	a0,0x2
ffffffffc0200b68:	d1c50513          	addi	a0,a0,-740 # ffffffffc0202880 <commands+0x678>
ffffffffc0200b6c:	0009059b          	sext.w	a1,s2
ffffffffc0200b70:	d70ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
                cprintf("Exception type: breakpoint\n");
ffffffffc0200b74:	00002517          	auipc	a0,0x2
ffffffffc0200b78:	d2c50513          	addi	a0,a0,-724 # ffffffffc02028a0 <commands+0x698>
ffffffffc0200b7c:	d64ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    unsigned short half = *p;
ffffffffc0200b80:	00095783          	lhu	a5,0(s2)
    return ((half & 0x3) == 0x3) ? 4 : 2;
ffffffffc0200b84:	4711                	li	a4,4
ffffffffc0200b86:	8b8d                	andi	a5,a5,3
ffffffffc0200b88:	00878363          	beq	a5,s0,ffffffffc0200b8e <exception_handler+0xa4>
ffffffffc0200b8c:	4709                	li	a4,2
}
ffffffffc0200b8e:	70a2                	ld	ra,40(sp)
ffffffffc0200b90:	7402                	ld	s0,32(sp)
                tf->epc = epc + rv_insn_len(epc);
ffffffffc0200b92:	993a                	add	s2,s2,a4
ffffffffc0200b94:	1124b423          	sd	s2,264(s1)
}
ffffffffc0200b98:	69a2                	ld	s3,8(sp)
ffffffffc0200b9a:	64e2                	ld	s1,24(sp)
ffffffffc0200b9c:	6942                	ld	s2,16(sp)
ffffffffc0200b9e:	6145                	addi	sp,sp,48
ffffffffc0200ba0:	8082                	ret
    return ((half & 0x3) == 0x3) ? 4 : 2;
ffffffffc0200ba2:	4411                	li	s0,4
ffffffffc0200ba4:	bf49                	j	ffffffffc0200b36 <exception_handler+0x4c>

ffffffffc0200ba6 <trap>:

static inline void trap_dispatch(struct trapframe *tf) {
    if ((intptr_t)tf->cause < 0) {
ffffffffc0200ba6:	11853783          	ld	a5,280(a0)
ffffffffc0200baa:	0007c363          	bltz	a5,ffffffffc0200bb0 <trap+0xa>
        // interrupts
        interrupt_handler(tf);
    } else {
        // exceptions
        exception_handler(tf);
ffffffffc0200bae:	bf35                	j	ffffffffc0200aea <exception_handler>
        interrupt_handler(tf);
ffffffffc0200bb0:	bd8d                	j	ffffffffc0200a22 <interrupt_handler>
	...

ffffffffc0200bb4 <__alltraps>:
    .endm

    .globl __alltraps
    .align(2)
__alltraps:
    SAVE_ALL
ffffffffc0200bb4:	14011073          	csrw	sscratch,sp
ffffffffc0200bb8:	712d                	addi	sp,sp,-288
ffffffffc0200bba:	e002                	sd	zero,0(sp)
ffffffffc0200bbc:	e406                	sd	ra,8(sp)
ffffffffc0200bbe:	ec0e                	sd	gp,24(sp)
ffffffffc0200bc0:	f012                	sd	tp,32(sp)
ffffffffc0200bc2:	f416                	sd	t0,40(sp)
ffffffffc0200bc4:	f81a                	sd	t1,48(sp)
ffffffffc0200bc6:	fc1e                	sd	t2,56(sp)
ffffffffc0200bc8:	e0a2                	sd	s0,64(sp)
ffffffffc0200bca:	e4a6                	sd	s1,72(sp)
ffffffffc0200bcc:	e8aa                	sd	a0,80(sp)
ffffffffc0200bce:	ecae                	sd	a1,88(sp)
ffffffffc0200bd0:	f0b2                	sd	a2,96(sp)
ffffffffc0200bd2:	f4b6                	sd	a3,104(sp)
ffffffffc0200bd4:	f8ba                	sd	a4,112(sp)
ffffffffc0200bd6:	fcbe                	sd	a5,120(sp)
ffffffffc0200bd8:	e142                	sd	a6,128(sp)
ffffffffc0200bda:	e546                	sd	a7,136(sp)
ffffffffc0200bdc:	e94a                	sd	s2,144(sp)
ffffffffc0200bde:	ed4e                	sd	s3,152(sp)
ffffffffc0200be0:	f152                	sd	s4,160(sp)
ffffffffc0200be2:	f556                	sd	s5,168(sp)
ffffffffc0200be4:	f95a                	sd	s6,176(sp)
ffffffffc0200be6:	fd5e                	sd	s7,184(sp)
ffffffffc0200be8:	e1e2                	sd	s8,192(sp)
ffffffffc0200bea:	e5e6                	sd	s9,200(sp)
ffffffffc0200bec:	e9ea                	sd	s10,208(sp)
ffffffffc0200bee:	edee                	sd	s11,216(sp)
ffffffffc0200bf0:	f1f2                	sd	t3,224(sp)
ffffffffc0200bf2:	f5f6                	sd	t4,232(sp)
ffffffffc0200bf4:	f9fa                	sd	t5,240(sp)
ffffffffc0200bf6:	fdfe                	sd	t6,248(sp)
ffffffffc0200bf8:	14001473          	csrrw	s0,sscratch,zero
ffffffffc0200bfc:	100024f3          	csrr	s1,sstatus
ffffffffc0200c00:	14102973          	csrr	s2,sepc
ffffffffc0200c04:	143029f3          	csrr	s3,stval
ffffffffc0200c08:	14202a73          	csrr	s4,scause
ffffffffc0200c0c:	e822                	sd	s0,16(sp)
ffffffffc0200c0e:	e226                	sd	s1,256(sp)
ffffffffc0200c10:	e64a                	sd	s2,264(sp)
ffffffffc0200c12:	ea4e                	sd	s3,272(sp)
ffffffffc0200c14:	ee52                	sd	s4,280(sp)

    move  a0, sp
ffffffffc0200c16:	850a                	mv	a0,sp
    jal trap
ffffffffc0200c18:	f8fff0ef          	jal	ra,ffffffffc0200ba6 <trap>

ffffffffc0200c1c <__trapret>:
    # sp should be the same as before "jal trap"

    .globl __trapret
__trapret:
    RESTORE_ALL
ffffffffc0200c1c:	6492                	ld	s1,256(sp)
ffffffffc0200c1e:	6932                	ld	s2,264(sp)
ffffffffc0200c20:	10049073          	csrw	sstatus,s1
ffffffffc0200c24:	14191073          	csrw	sepc,s2
ffffffffc0200c28:	60a2                	ld	ra,8(sp)
ffffffffc0200c2a:	61e2                	ld	gp,24(sp)
ffffffffc0200c2c:	7202                	ld	tp,32(sp)
ffffffffc0200c2e:	72a2                	ld	t0,40(sp)
ffffffffc0200c30:	7342                	ld	t1,48(sp)
ffffffffc0200c32:	73e2                	ld	t2,56(sp)
ffffffffc0200c34:	6406                	ld	s0,64(sp)
ffffffffc0200c36:	64a6                	ld	s1,72(sp)
ffffffffc0200c38:	6546                	ld	a0,80(sp)
ffffffffc0200c3a:	65e6                	ld	a1,88(sp)
ffffffffc0200c3c:	7606                	ld	a2,96(sp)
ffffffffc0200c3e:	76a6                	ld	a3,104(sp)
ffffffffc0200c40:	7746                	ld	a4,112(sp)
ffffffffc0200c42:	77e6                	ld	a5,120(sp)
ffffffffc0200c44:	680a                	ld	a6,128(sp)
ffffffffc0200c46:	68aa                	ld	a7,136(sp)
ffffffffc0200c48:	694a                	ld	s2,144(sp)
ffffffffc0200c4a:	69ea                	ld	s3,152(sp)
ffffffffc0200c4c:	7a0a                	ld	s4,160(sp)
ffffffffc0200c4e:	7aaa                	ld	s5,168(sp)
ffffffffc0200c50:	7b4a                	ld	s6,176(sp)
ffffffffc0200c52:	7bea                	ld	s7,184(sp)
ffffffffc0200c54:	6c0e                	ld	s8,192(sp)
ffffffffc0200c56:	6cae                	ld	s9,200(sp)
ffffffffc0200c58:	6d4e                	ld	s10,208(sp)
ffffffffc0200c5a:	6dee                	ld	s11,216(sp)
ffffffffc0200c5c:	7e0e                	ld	t3,224(sp)
ffffffffc0200c5e:	7eae                	ld	t4,232(sp)
ffffffffc0200c60:	7f4e                	ld	t5,240(sp)
ffffffffc0200c62:	7fee                	ld	t6,248(sp)
ffffffffc0200c64:	6142                	ld	sp,16(sp)
    # return from supervisor call
    sret
ffffffffc0200c66:	10200073          	sret

ffffffffc0200c6a <alloc_pages>:
#include <defs.h>
#include <intr.h>
#include <riscv.h>

static inline bool __intr_save(void) {
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0200c6a:	100027f3          	csrr	a5,sstatus
ffffffffc0200c6e:	8b89                	andi	a5,a5,2
ffffffffc0200c70:	eb81                	bnez	a5,ffffffffc0200c80 <alloc_pages+0x16>
struct Page *alloc_pages(size_t n) {
    struct Page *page = NULL;
    bool intr_flag;
    local_intr_save(intr_flag);
    {
        page = pmm_manager->alloc_pages(n);
ffffffffc0200c72:	00007797          	auipc	a5,0x7
ffffffffc0200c76:	8167b783          	ld	a5,-2026(a5) # ffffffffc0207488 <pmm_manager>
ffffffffc0200c7a:	0187b303          	ld	t1,24(a5)
ffffffffc0200c7e:	8302                	jr	t1
struct Page *alloc_pages(size_t n) {
ffffffffc0200c80:	1141                	addi	sp,sp,-16
ffffffffc0200c82:	e406                	sd	ra,8(sp)
ffffffffc0200c84:	e022                	sd	s0,0(sp)
ffffffffc0200c86:	842a                	mv	s0,a0
        intr_disable();
ffffffffc0200c88:	b53ff0ef          	jal	ra,ffffffffc02007da <intr_disable>
        page = pmm_manager->alloc_pages(n);
ffffffffc0200c8c:	00006797          	auipc	a5,0x6
ffffffffc0200c90:	7fc7b783          	ld	a5,2044(a5) # ffffffffc0207488 <pmm_manager>
ffffffffc0200c94:	6f9c                	ld	a5,24(a5)
ffffffffc0200c96:	8522                	mv	a0,s0
ffffffffc0200c98:	9782                	jalr	a5
ffffffffc0200c9a:	842a                	mv	s0,a0
    return 0;
}

static inline void __intr_restore(bool flag) {
    if (flag) {
        intr_enable();
ffffffffc0200c9c:	b39ff0ef          	jal	ra,ffffffffc02007d4 <intr_enable>
    }
    local_intr_restore(intr_flag);
    return page;
}
ffffffffc0200ca0:	60a2                	ld	ra,8(sp)
ffffffffc0200ca2:	8522                	mv	a0,s0
ffffffffc0200ca4:	6402                	ld	s0,0(sp)
ffffffffc0200ca6:	0141                	addi	sp,sp,16
ffffffffc0200ca8:	8082                	ret

ffffffffc0200caa <free_pages>:
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0200caa:	100027f3          	csrr	a5,sstatus
ffffffffc0200cae:	8b89                	andi	a5,a5,2
ffffffffc0200cb0:	eb81                	bnez	a5,ffffffffc0200cc0 <free_pages+0x16>
// free_pages - call pmm->free_pages to free a continuous n*PAGESIZE memory
void free_pages(struct Page *base, size_t n) {
    bool intr_flag;
    local_intr_save(intr_flag);
    {
        pmm_manager->free_pages(base, n);
ffffffffc0200cb2:	00006797          	auipc	a5,0x6
ffffffffc0200cb6:	7d67b783          	ld	a5,2006(a5) # ffffffffc0207488 <pmm_manager>
ffffffffc0200cba:	0207b303          	ld	t1,32(a5)
ffffffffc0200cbe:	8302                	jr	t1
void free_pages(struct Page *base, size_t n) {
ffffffffc0200cc0:	1101                	addi	sp,sp,-32
ffffffffc0200cc2:	ec06                	sd	ra,24(sp)
ffffffffc0200cc4:	e822                	sd	s0,16(sp)
ffffffffc0200cc6:	e426                	sd	s1,8(sp)
ffffffffc0200cc8:	842a                	mv	s0,a0
ffffffffc0200cca:	84ae                	mv	s1,a1
        intr_disable();
ffffffffc0200ccc:	b0fff0ef          	jal	ra,ffffffffc02007da <intr_disable>
        pmm_manager->free_pages(base, n);
ffffffffc0200cd0:	00006797          	auipc	a5,0x6
ffffffffc0200cd4:	7b87b783          	ld	a5,1976(a5) # ffffffffc0207488 <pmm_manager>
ffffffffc0200cd8:	739c                	ld	a5,32(a5)
ffffffffc0200cda:	85a6                	mv	a1,s1
ffffffffc0200cdc:	8522                	mv	a0,s0
ffffffffc0200cde:	9782                	jalr	a5
    }
    local_intr_restore(intr_flag);
}
ffffffffc0200ce0:	6442                	ld	s0,16(sp)
ffffffffc0200ce2:	60e2                	ld	ra,24(sp)
ffffffffc0200ce4:	64a2                	ld	s1,8(sp)
ffffffffc0200ce6:	6105                	addi	sp,sp,32
        intr_enable();
ffffffffc0200ce8:	b4f5                	j	ffffffffc02007d4 <intr_enable>

ffffffffc0200cea <nr_free_pages>:
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0200cea:	100027f3          	csrr	a5,sstatus
ffffffffc0200cee:	8b89                	andi	a5,a5,2
ffffffffc0200cf0:	eb81                	bnez	a5,ffffffffc0200d00 <nr_free_pages+0x16>
size_t nr_free_pages(void) {
    size_t ret;
    bool intr_flag;
    local_intr_save(intr_flag);
    {
        ret = pmm_manager->nr_free_pages();
ffffffffc0200cf2:	00006797          	auipc	a5,0x6
ffffffffc0200cf6:	7967b783          	ld	a5,1942(a5) # ffffffffc0207488 <pmm_manager>
ffffffffc0200cfa:	0287b303          	ld	t1,40(a5)
ffffffffc0200cfe:	8302                	jr	t1
size_t nr_free_pages(void) {
ffffffffc0200d00:	1141                	addi	sp,sp,-16
ffffffffc0200d02:	e406                	sd	ra,8(sp)
ffffffffc0200d04:	e022                	sd	s0,0(sp)
        intr_disable();
ffffffffc0200d06:	ad5ff0ef          	jal	ra,ffffffffc02007da <intr_disable>
        ret = pmm_manager->nr_free_pages();
ffffffffc0200d0a:	00006797          	auipc	a5,0x6
ffffffffc0200d0e:	77e7b783          	ld	a5,1918(a5) # ffffffffc0207488 <pmm_manager>
ffffffffc0200d12:	779c                	ld	a5,40(a5)
ffffffffc0200d14:	9782                	jalr	a5
ffffffffc0200d16:	842a                	mv	s0,a0
        intr_enable();
ffffffffc0200d18:	abdff0ef          	jal	ra,ffffffffc02007d4 <intr_enable>
    }
    local_intr_restore(intr_flag);
    return ret;
}
ffffffffc0200d1c:	60a2                	ld	ra,8(sp)
ffffffffc0200d1e:	8522                	mv	a0,s0
ffffffffc0200d20:	6402                	ld	s0,0(sp)
ffffffffc0200d22:	0141                	addi	sp,sp,16
ffffffffc0200d24:	8082                	ret

ffffffffc0200d26 <pmm_init>:
    pmm_manager = &default_pmm_manager;
ffffffffc0200d26:	00002797          	auipc	a5,0x2
ffffffffc0200d2a:	0a278793          	addi	a5,a5,162 # ffffffffc0202dc8 <default_pmm_manager>
    cprintf("memory management: %s\n", pmm_manager->name);
ffffffffc0200d2e:	638c                	ld	a1,0(a5)
        init_memmap(pa2page(mem_begin), (mem_end - mem_begin) / PGSIZE);
    }
}

/* pmm_init - initialize the physical memory management */
void pmm_init(void) {
ffffffffc0200d30:	7179                	addi	sp,sp,-48
ffffffffc0200d32:	ec26                	sd	s1,24(sp)
    cprintf("memory management: %s\n", pmm_manager->name);
ffffffffc0200d34:	00002517          	auipc	a0,0x2
ffffffffc0200d38:	b8c50513          	addi	a0,a0,-1140 # ffffffffc02028c0 <commands+0x6b8>
    pmm_manager = &default_pmm_manager;
ffffffffc0200d3c:	00006497          	auipc	s1,0x6
ffffffffc0200d40:	74c48493          	addi	s1,s1,1868 # ffffffffc0207488 <pmm_manager>
void pmm_init(void) {
ffffffffc0200d44:	f406                	sd	ra,40(sp)
ffffffffc0200d46:	f022                	sd	s0,32(sp)
ffffffffc0200d48:	e44e                	sd	s3,8(sp)
ffffffffc0200d4a:	e84a                	sd	s2,16(sp)
ffffffffc0200d4c:	e052                	sd	s4,0(sp)
    pmm_manager = &default_pmm_manager;
ffffffffc0200d4e:	e09c                	sd	a5,0(s1)
    cprintf("memory management: %s\n", pmm_manager->name);
ffffffffc0200d50:	b90ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    pmm_manager->init();
ffffffffc0200d54:	609c                	ld	a5,0(s1)
    va_pa_offset = PHYSICAL_MEMORY_OFFSET;
ffffffffc0200d56:	00006417          	auipc	s0,0x6
ffffffffc0200d5a:	73a40413          	addi	s0,s0,1850 # ffffffffc0207490 <va_pa_offset>
    pmm_manager->init();
ffffffffc0200d5e:	679c                	ld	a5,8(a5)
ffffffffc0200d60:	9782                	jalr	a5
    va_pa_offset = PHYSICAL_MEMORY_OFFSET;
ffffffffc0200d62:	57f5                	li	a5,-3
ffffffffc0200d64:	07fa                	slli	a5,a5,0x1e
ffffffffc0200d66:	e01c                	sd	a5,0(s0)
    uint64_t mem_begin = get_memory_base();
ffffffffc0200d68:	a09ff0ef          	jal	ra,ffffffffc0200770 <get_memory_base>
ffffffffc0200d6c:	89aa                	mv	s3,a0
    uint64_t mem_size  = get_memory_size();
ffffffffc0200d6e:	a0dff0ef          	jal	ra,ffffffffc020077a <get_memory_size>
    if (mem_size == 0) {
ffffffffc0200d72:	14050663          	beqz	a0,ffffffffc0200ebe <pmm_init+0x198>
    uint64_t mem_end   = mem_begin + mem_size;
ffffffffc0200d76:	892a                	mv	s2,a0
    cprintf("physcial memory map:\n");
ffffffffc0200d78:	00002517          	auipc	a0,0x2
ffffffffc0200d7c:	b9050513          	addi	a0,a0,-1136 # ffffffffc0202908 <commands+0x700>
ffffffffc0200d80:	b60ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    uint64_t mem_end   = mem_begin + mem_size;
ffffffffc0200d84:	01298a33          	add	s4,s3,s2
    cprintf("  memory: 0x%016lx, [0x%016lx, 0x%016lx].\n", mem_size, mem_begin,
ffffffffc0200d88:	fffa0693          	addi	a3,s4,-1
ffffffffc0200d8c:	864e                	mv	a2,s3
ffffffffc0200d8e:	85ca                	mv	a1,s2
ffffffffc0200d90:	00002517          	auipc	a0,0x2
ffffffffc0200d94:	b9050513          	addi	a0,a0,-1136 # ffffffffc0202920 <commands+0x718>
ffffffffc0200d98:	b48ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    npage = maxpa / PGSIZE;
ffffffffc0200d9c:	c80007b7          	lui	a5,0xc8000
ffffffffc0200da0:	8752                	mv	a4,s4
ffffffffc0200da2:	0d47e963          	bltu	a5,s4,ffffffffc0200e74 <pmm_init+0x14e>
ffffffffc0200da6:	00007797          	auipc	a5,0x7
ffffffffc0200daa:	6f978793          	addi	a5,a5,1785 # ffffffffc020849f <end+0xfff>
ffffffffc0200dae:	757d                	lui	a0,0xfffff
ffffffffc0200db0:	8331                	srli	a4,a4,0xc
ffffffffc0200db2:	00006817          	auipc	a6,0x6
ffffffffc0200db6:	6ae80813          	addi	a6,a6,1710 # ffffffffc0207460 <npage>
ffffffffc0200dba:	8fe9                	and	a5,a5,a0
    pages = (struct Page *)ROUNDUP((void *)end, PGSIZE);
ffffffffc0200dbc:	00006597          	auipc	a1,0x6
ffffffffc0200dc0:	6dc58593          	addi	a1,a1,1756 # ffffffffc0207498 <pages>
    npage = maxpa / PGSIZE;
ffffffffc0200dc4:	00e83023          	sd	a4,0(a6)
    pages = (struct Page *)ROUNDUP((void *)end, PGSIZE);
ffffffffc0200dc8:	e19c                	sd	a5,0(a1)
    for (size_t i = 0; i < npage - nbase; i++) {
ffffffffc0200dca:	000806b7          	lui	a3,0x80
ffffffffc0200dce:	02d70763          	beq	a4,a3,ffffffffc0200dfc <pmm_init+0xd6>
ffffffffc0200dd2:	4601                	li	a2,0
ffffffffc0200dd4:	4681                	li	a3,0
 *
 * Note that @nr may be almost arbitrarily large; this function is not
 * restricted to acting on a single-word quantity.
 * */
static inline void set_bit(int nr, volatile void *addr) {
    __op_bit(or, __NOP, nr, ((volatile unsigned long *)addr));
ffffffffc0200dd6:	4885                	li	a7,1
ffffffffc0200dd8:	fff80537          	lui	a0,0xfff80
ffffffffc0200ddc:	a011                	j	ffffffffc0200de0 <pmm_init+0xba>
ffffffffc0200dde:	619c                	ld	a5,0(a1)
        SetPageReserved(pages + i);
ffffffffc0200de0:	97b2                	add	a5,a5,a2
ffffffffc0200de2:	07a1                	addi	a5,a5,8
ffffffffc0200de4:	4117b02f          	amoor.d	zero,a7,(a5)
    for (size_t i = 0; i < npage - nbase; i++) {
ffffffffc0200de8:	00083703          	ld	a4,0(a6)
ffffffffc0200dec:	0685                	addi	a3,a3,1
ffffffffc0200dee:	02860613          	addi	a2,a2,40
ffffffffc0200df2:	00a707b3          	add	a5,a4,a0
ffffffffc0200df6:	fef6e4e3          	bltu	a3,a5,ffffffffc0200dde <pmm_init+0xb8>
ffffffffc0200dfa:	619c                	ld	a5,0(a1)
    uintptr_t freemem = PADDR((uintptr_t)pages + sizeof(struct Page) * (npage - nbase));
ffffffffc0200dfc:	00271693          	slli	a3,a4,0x2
ffffffffc0200e00:	96ba                	add	a3,a3,a4
ffffffffc0200e02:	fec00637          	lui	a2,0xfec00
ffffffffc0200e06:	963e                	add	a2,a2,a5
ffffffffc0200e08:	068e                	slli	a3,a3,0x3
ffffffffc0200e0a:	96b2                	add	a3,a3,a2
ffffffffc0200e0c:	c0200637          	lui	a2,0xc0200
ffffffffc0200e10:	08c6eb63          	bltu	a3,a2,ffffffffc0200ea6 <pmm_init+0x180>
ffffffffc0200e14:	6008                	ld	a0,0(s0)
    mem_end = ROUNDDOWN(mem_end, PGSIZE);
ffffffffc0200e16:	767d                	lui	a2,0xfffff
ffffffffc0200e18:	00ca75b3          	and	a1,s4,a2
    uintptr_t freemem = PADDR((uintptr_t)pages + sizeof(struct Page) * (npage - nbase));
ffffffffc0200e1c:	8e89                	sub	a3,a3,a0
    if (freemem < mem_end) {
ffffffffc0200e1e:	04b6ee63          	bltu	a3,a1,ffffffffc0200e7a <pmm_init+0x154>
    satp_physical = PADDR(satp_virtual);
    cprintf("satp virtual address: 0x%016lx\nsatp physical address: 0x%016lx\n", satp_virtual, satp_physical);
}

static void check_alloc_page(void) {
    pmm_manager->check();
ffffffffc0200e22:	609c                	ld	a5,0(s1)
ffffffffc0200e24:	7b9c                	ld	a5,48(a5)
ffffffffc0200e26:	9782                	jalr	a5
    cprintf("check_alloc_page() succeeded!\n");
ffffffffc0200e28:	00002517          	auipc	a0,0x2
ffffffffc0200e2c:	b8050513          	addi	a0,a0,-1152 # ffffffffc02029a8 <commands+0x7a0>
ffffffffc0200e30:	ab0ff0ef          	jal	ra,ffffffffc02000e0 <cprintf>
    satp_virtual = (pte_t*)boot_page_table_sv39;
ffffffffc0200e34:	00005597          	auipc	a1,0x5
ffffffffc0200e38:	1cc58593          	addi	a1,a1,460 # ffffffffc0206000 <boot_page_table_sv39>
ffffffffc0200e3c:	00006797          	auipc	a5,0x6
ffffffffc0200e40:	62b7b623          	sd	a1,1580(a5) # ffffffffc0207468 <satp_virtual>
    satp_physical = PADDR(satp_virtual);
ffffffffc0200e44:	c02007b7          	lui	a5,0xc0200
ffffffffc0200e48:	08f5e763          	bltu	a1,a5,ffffffffc0200ed6 <pmm_init+0x1b0>
ffffffffc0200e4c:	6010                	ld	a2,0(s0)
}
ffffffffc0200e4e:	7402                	ld	s0,32(sp)
ffffffffc0200e50:	70a2                	ld	ra,40(sp)
ffffffffc0200e52:	64e2                	ld	s1,24(sp)
ffffffffc0200e54:	6942                	ld	s2,16(sp)
ffffffffc0200e56:	69a2                	ld	s3,8(sp)
ffffffffc0200e58:	6a02                	ld	s4,0(sp)
    satp_physical = PADDR(satp_virtual);
ffffffffc0200e5a:	40c58633          	sub	a2,a1,a2
ffffffffc0200e5e:	00006797          	auipc	a5,0x6
ffffffffc0200e62:	62c7b123          	sd	a2,1570(a5) # ffffffffc0207480 <satp_physical>
    cprintf("satp virtual address: 0x%016lx\nsatp physical address: 0x%016lx\n", satp_virtual, satp_physical);
ffffffffc0200e66:	00002517          	auipc	a0,0x2
ffffffffc0200e6a:	b6250513          	addi	a0,a0,-1182 # ffffffffc02029c8 <commands+0x7c0>
}
ffffffffc0200e6e:	6145                	addi	sp,sp,48
    cprintf("satp virtual address: 0x%016lx\nsatp physical address: 0x%016lx\n", satp_virtual, satp_physical);
ffffffffc0200e70:	a70ff06f          	j	ffffffffc02000e0 <cprintf>
    npage = maxpa / PGSIZE;
ffffffffc0200e74:	c8000737          	lui	a4,0xc8000
ffffffffc0200e78:	b73d                	j	ffffffffc0200da6 <pmm_init+0x80>
    mem_begin = ROUNDUP(freemem, PGSIZE);
ffffffffc0200e7a:	6505                	lui	a0,0x1
ffffffffc0200e7c:	157d                	addi	a0,a0,-1
ffffffffc0200e7e:	96aa                	add	a3,a3,a0
ffffffffc0200e80:	8ef1                	and	a3,a3,a2
static inline int page_ref_dec(struct Page *page) {
    page->ref -= 1;
    return page->ref;
}
static inline struct Page *pa2page(uintptr_t pa) {
    if (PPN(pa) >= npage) {
ffffffffc0200e82:	00c6d513          	srli	a0,a3,0xc
ffffffffc0200e86:	06e57563          	bgeu	a0,a4,ffffffffc0200ef0 <pmm_init+0x1ca>
    pmm_manager->init_memmap(base, n);
ffffffffc0200e8a:	6090                	ld	a2,0(s1)
        panic("pa2page called with invalid pa");
    }
    return &pages[PPN(pa) - nbase];
ffffffffc0200e8c:	fff80737          	lui	a4,0xfff80
ffffffffc0200e90:	972a                	add	a4,a4,a0
ffffffffc0200e92:	00271513          	slli	a0,a4,0x2
ffffffffc0200e96:	953a                	add	a0,a0,a4
ffffffffc0200e98:	6a18                	ld	a4,16(a2)
        init_memmap(pa2page(mem_begin), (mem_end - mem_begin) / PGSIZE);
ffffffffc0200e9a:	8d95                	sub	a1,a1,a3
ffffffffc0200e9c:	050e                	slli	a0,a0,0x3
    pmm_manager->init_memmap(base, n);
ffffffffc0200e9e:	81b1                	srli	a1,a1,0xc
ffffffffc0200ea0:	953e                	add	a0,a0,a5
ffffffffc0200ea2:	9702                	jalr	a4
}
ffffffffc0200ea4:	bfbd                	j	ffffffffc0200e22 <pmm_init+0xfc>
    uintptr_t freemem = PADDR((uintptr_t)pages + sizeof(struct Page) * (npage - nbase));
ffffffffc0200ea6:	00002617          	auipc	a2,0x2
ffffffffc0200eaa:	aaa60613          	addi	a2,a2,-1366 # ffffffffc0202950 <commands+0x748>
ffffffffc0200eae:	07100593          	li	a1,113
ffffffffc0200eb2:	00002517          	auipc	a0,0x2
ffffffffc0200eb6:	a4650513          	addi	a0,a0,-1466 # ffffffffc02028f8 <commands+0x6f0>
ffffffffc0200eba:	aaeff0ef          	jal	ra,ffffffffc0200168 <__panic>
        panic("DTB memory info not available");
ffffffffc0200ebe:	00002617          	auipc	a2,0x2
ffffffffc0200ec2:	a1a60613          	addi	a2,a2,-1510 # ffffffffc02028d8 <commands+0x6d0>
ffffffffc0200ec6:	05a00593          	li	a1,90
ffffffffc0200eca:	00002517          	auipc	a0,0x2
ffffffffc0200ece:	a2e50513          	addi	a0,a0,-1490 # ffffffffc02028f8 <commands+0x6f0>
ffffffffc0200ed2:	a96ff0ef          	jal	ra,ffffffffc0200168 <__panic>
    satp_physical = PADDR(satp_virtual);
ffffffffc0200ed6:	86ae                	mv	a3,a1
ffffffffc0200ed8:	00002617          	auipc	a2,0x2
ffffffffc0200edc:	a7860613          	addi	a2,a2,-1416 # ffffffffc0202950 <commands+0x748>
ffffffffc0200ee0:	08c00593          	li	a1,140
ffffffffc0200ee4:	00002517          	auipc	a0,0x2
ffffffffc0200ee8:	a1450513          	addi	a0,a0,-1516 # ffffffffc02028f8 <commands+0x6f0>
ffffffffc0200eec:	a7cff0ef          	jal	ra,ffffffffc0200168 <__panic>
        panic("pa2page called with invalid pa");
ffffffffc0200ef0:	00002617          	auipc	a2,0x2
ffffffffc0200ef4:	a8860613          	addi	a2,a2,-1400 # ffffffffc0202978 <commands+0x770>
ffffffffc0200ef8:	06b00593          	li	a1,107
ffffffffc0200efc:	00002517          	auipc	a0,0x2
ffffffffc0200f00:	a9c50513          	addi	a0,a0,-1380 # ffffffffc0202998 <commands+0x790>
ffffffffc0200f04:	a64ff0ef          	jal	ra,ffffffffc0200168 <__panic>

ffffffffc0200f08 <default_init>:
 * list_init - initialize a new entry
 * @elm:        new entry to be initialized
 * */
static inline void
list_init(list_entry_t *elm) {
    elm->prev = elm->next = elm;
ffffffffc0200f08:	00006797          	auipc	a5,0x6
ffffffffc0200f0c:	12078793          	addi	a5,a5,288 # ffffffffc0207028 <free_area>
ffffffffc0200f10:	e79c                	sd	a5,8(a5)
ffffffffc0200f12:	e39c                	sd	a5,0(a5)
#define nr_free (free_area.nr_free)

static void
default_init(void) {
    list_init(&free_list);
    nr_free = 0;
ffffffffc0200f14:	0007a823          	sw	zero,16(a5)
}
ffffffffc0200f18:	8082                	ret

ffffffffc0200f1a <default_nr_free_pages>:
}

static size_t
default_nr_free_pages(void) {
    return nr_free;
}
ffffffffc0200f1a:	00006517          	auipc	a0,0x6
ffffffffc0200f1e:	11e56503          	lwu	a0,286(a0) # ffffffffc0207038 <free_area+0x10>
ffffffffc0200f22:	8082                	ret

ffffffffc0200f24 <default_check>:
}

// LAB2: below code is used to check the first fit allocation algorithm (your EXERCISE 1) 
// NOTICE: You SHOULD NOT CHANGE basic_check, default_check functions!
static void
default_check(void) {
ffffffffc0200f24:	715d                	addi	sp,sp,-80
ffffffffc0200f26:	e0a2                	sd	s0,64(sp)
 * list_next - get the next entry
 * @listelm:    the list head
 **/
static inline list_entry_t *
list_next(list_entry_t *listelm) {
    return listelm->next;
ffffffffc0200f28:	00006417          	auipc	s0,0x6
ffffffffc0200f2c:	10040413          	addi	s0,s0,256 # ffffffffc0207028 <free_area>
ffffffffc0200f30:	641c                	ld	a5,8(s0)
ffffffffc0200f32:	e486                	sd	ra,72(sp)
ffffffffc0200f34:	fc26                	sd	s1,56(sp)
ffffffffc0200f36:	f84a                	sd	s2,48(sp)
ffffffffc0200f38:	f44e                	sd	s3,40(sp)
ffffffffc0200f3a:	f052                	sd	s4,32(sp)
ffffffffc0200f3c:	ec56                	sd	s5,24(sp)
ffffffffc0200f3e:	e85a                	sd	s6,16(sp)
ffffffffc0200f40:	e45e                	sd	s7,8(sp)
ffffffffc0200f42:	e062                	sd	s8,0(sp)
    int count = 0, total = 0;
    list_entry_t *le = &free_list;
    while ((le = list_next(le)) != &free_list) {
ffffffffc0200f44:	2c878763          	beq	a5,s0,ffffffffc0201212 <default_check+0x2ee>
    int count = 0, total = 0;
ffffffffc0200f48:	4481                	li	s1,0
ffffffffc0200f4a:	4901                	li	s2,0
 * test_bit - Determine whether a bit is set
 * @nr:     the bit to test
 * @addr:   the address to count from
 * */
static inline bool test_bit(int nr, volatile void *addr) {
    return (((*(volatile unsigned long *)addr) >> nr) & 1);
ffffffffc0200f4c:	ff07b703          	ld	a4,-16(a5)
        struct Page *p = le2page(le, page_link);
        assert(PageProperty(p));
ffffffffc0200f50:	8b09                	andi	a4,a4,2
ffffffffc0200f52:	2c070463          	beqz	a4,ffffffffc020121a <default_check+0x2f6>
        count ++, total += p->property;
ffffffffc0200f56:	ff87a703          	lw	a4,-8(a5)
ffffffffc0200f5a:	679c                	ld	a5,8(a5)
ffffffffc0200f5c:	2905                	addiw	s2,s2,1
ffffffffc0200f5e:	9cb9                	addw	s1,s1,a4
    while ((le = list_next(le)) != &free_list) {
ffffffffc0200f60:	fe8796e3          	bne	a5,s0,ffffffffc0200f4c <default_check+0x28>
ffffffffc0200f64:	89a6                	mv	s3,s1
    }
    assert(total == nr_free_pages());
ffffffffc0200f66:	d85ff0ef          	jal	ra,ffffffffc0200cea <nr_free_pages>
ffffffffc0200f6a:	71351863          	bne	a0,s3,ffffffffc020167a <default_check+0x756>
    assert((p0 = alloc_page()) != NULL);
ffffffffc0200f6e:	4505                	li	a0,1
ffffffffc0200f70:	cfbff0ef          	jal	ra,ffffffffc0200c6a <alloc_pages>
ffffffffc0200f74:	8a2a                	mv	s4,a0
ffffffffc0200f76:	44050263          	beqz	a0,ffffffffc02013ba <default_check+0x496>
    assert((p1 = alloc_page()) != NULL);
ffffffffc0200f7a:	4505                	li	a0,1
ffffffffc0200f7c:	cefff0ef          	jal	ra,ffffffffc0200c6a <alloc_pages>
ffffffffc0200f80:	89aa                	mv	s3,a0
ffffffffc0200f82:	70050c63          	beqz	a0,ffffffffc020169a <default_check+0x776>
    assert((p2 = alloc_page()) != NULL);
ffffffffc0200f86:	4505                	li	a0,1
ffffffffc0200f88:	ce3ff0ef          	jal	ra,ffffffffc0200c6a <alloc_pages>
ffffffffc0200f8c:	8aaa                	mv	s5,a0
ffffffffc0200f8e:	4a050663          	beqz	a0,ffffffffc020143a <default_check+0x516>
    assert(p0 != p1 && p0 != p2 && p1 != p2);
ffffffffc0200f92:	2b3a0463          	beq	s4,s3,ffffffffc020123a <default_check+0x316>
ffffffffc0200f96:	2aaa0263          	beq	s4,a0,ffffffffc020123a <default_check+0x316>
ffffffffc0200f9a:	2aa98063          	beq	s3,a0,ffffffffc020123a <default_check+0x316>
    assert(page_ref(p0) == 0 && page_ref(p1) == 0 && page_ref(p2) == 0);
ffffffffc0200f9e:	000a2783          	lw	a5,0(s4)
ffffffffc0200fa2:	2a079c63          	bnez	a5,ffffffffc020125a <default_check+0x336>
ffffffffc0200fa6:	0009a783          	lw	a5,0(s3)
ffffffffc0200faa:	2a079863          	bnez	a5,ffffffffc020125a <default_check+0x336>
ffffffffc0200fae:	411c                	lw	a5,0(a0)
ffffffffc0200fb0:	2a079563          	bnez	a5,ffffffffc020125a <default_check+0x336>
static inline ppn_t page2ppn(struct Page *page) { return page - pages + nbase; }
ffffffffc0200fb4:	00006797          	auipc	a5,0x6
ffffffffc0200fb8:	4e47b783          	ld	a5,1252(a5) # ffffffffc0207498 <pages>
ffffffffc0200fbc:	40fa0733          	sub	a4,s4,a5
ffffffffc0200fc0:	870d                	srai	a4,a4,0x3
ffffffffc0200fc2:	00002597          	auipc	a1,0x2
ffffffffc0200fc6:	08e5b583          	ld	a1,142(a1) # ffffffffc0203050 <nbase+0x8>
ffffffffc0200fca:	02b70733          	mul	a4,a4,a1
ffffffffc0200fce:	00002617          	auipc	a2,0x2
ffffffffc0200fd2:	07a63603          	ld	a2,122(a2) # ffffffffc0203048 <nbase>
    assert(page2pa(p0) < npage * PGSIZE);
ffffffffc0200fd6:	00006697          	auipc	a3,0x6
ffffffffc0200fda:	48a6b683          	ld	a3,1162(a3) # ffffffffc0207460 <npage>
ffffffffc0200fde:	06b2                	slli	a3,a3,0xc
ffffffffc0200fe0:	9732                	add	a4,a4,a2
    return page2ppn(page) << PGSHIFT;
ffffffffc0200fe2:	0732                	slli	a4,a4,0xc
ffffffffc0200fe4:	28d77b63          	bgeu	a4,a3,ffffffffc020127a <default_check+0x356>
static inline ppn_t page2ppn(struct Page *page) { return page - pages + nbase; }
ffffffffc0200fe8:	40f98733          	sub	a4,s3,a5
ffffffffc0200fec:	870d                	srai	a4,a4,0x3
ffffffffc0200fee:	02b70733          	mul	a4,a4,a1
ffffffffc0200ff2:	9732                	add	a4,a4,a2
    return page2ppn(page) << PGSHIFT;
ffffffffc0200ff4:	0732                	slli	a4,a4,0xc
    assert(page2pa(p1) < npage * PGSIZE);
ffffffffc0200ff6:	4cd77263          	bgeu	a4,a3,ffffffffc02014ba <default_check+0x596>
static inline ppn_t page2ppn(struct Page *page) { return page - pages + nbase; }
ffffffffc0200ffa:	40f507b3          	sub	a5,a0,a5
ffffffffc0200ffe:	878d                	srai	a5,a5,0x3
ffffffffc0201000:	02b787b3          	mul	a5,a5,a1
ffffffffc0201004:	97b2                	add	a5,a5,a2
    return page2ppn(page) << PGSHIFT;
ffffffffc0201006:	07b2                	slli	a5,a5,0xc
    assert(page2pa(p2) < npage * PGSIZE);
ffffffffc0201008:	30d7f963          	bgeu	a5,a3,ffffffffc020131a <default_check+0x3f6>
    assert(alloc_page() == NULL);
ffffffffc020100c:	4505                	li	a0,1
    list_entry_t free_list_store = free_list;
ffffffffc020100e:	00043c03          	ld	s8,0(s0)
ffffffffc0201012:	00843b83          	ld	s7,8(s0)
    unsigned int nr_free_store = nr_free;
ffffffffc0201016:	01042b03          	lw	s6,16(s0)
    elm->prev = elm->next = elm;
ffffffffc020101a:	e400                	sd	s0,8(s0)
ffffffffc020101c:	e000                	sd	s0,0(s0)
    nr_free = 0;
ffffffffc020101e:	00006797          	auipc	a5,0x6
ffffffffc0201022:	0007ad23          	sw	zero,26(a5) # ffffffffc0207038 <free_area+0x10>
    assert(alloc_page() == NULL);
ffffffffc0201026:	c45ff0ef          	jal	ra,ffffffffc0200c6a <alloc_pages>
ffffffffc020102a:	2c051863          	bnez	a0,ffffffffc02012fa <default_check+0x3d6>
    free_page(p0);
ffffffffc020102e:	4585                	li	a1,1
ffffffffc0201030:	8552                	mv	a0,s4
ffffffffc0201032:	c79ff0ef          	jal	ra,ffffffffc0200caa <free_pages>
    free_page(p1);
ffffffffc0201036:	4585                	li	a1,1
ffffffffc0201038:	854e                	mv	a0,s3
ffffffffc020103a:	c71ff0ef          	jal	ra,ffffffffc0200caa <free_pages>
    free_page(p2);
ffffffffc020103e:	4585                	li	a1,1
ffffffffc0201040:	8556                	mv	a0,s5
ffffffffc0201042:	c69ff0ef          	jal	ra,ffffffffc0200caa <free_pages>
    assert(nr_free == 3);
ffffffffc0201046:	4818                	lw	a4,16(s0)
ffffffffc0201048:	478d                	li	a5,3
ffffffffc020104a:	28f71863          	bne	a4,a5,ffffffffc02012da <default_check+0x3b6>
    assert((p0 = alloc_page()) != NULL);
ffffffffc020104e:	4505                	li	a0,1
ffffffffc0201050:	c1bff0ef          	jal	ra,ffffffffc0200c6a <alloc_pages>
ffffffffc0201054:	89aa                	mv	s3,a0
ffffffffc0201056:	26050263          	beqz	a0,ffffffffc02012ba <default_check+0x396>
    assert((p1 = alloc_page()) != NULL);
ffffffffc020105a:	4505                	li	a0,1
ffffffffc020105c:	c0fff0ef          	jal	ra,ffffffffc0200c6a <alloc_pages>
ffffffffc0201060:	8aaa                	mv	s5,a0
ffffffffc0201062:	3a050c63          	beqz	a0,ffffffffc020141a <default_check+0x4f6>
    assert((p2 = alloc_page()) != NULL);
ffffffffc0201066:	4505                	li	a0,1
ffffffffc0201068:	c03ff0ef          	jal	ra,ffffffffc0200c6a <alloc_pages>
ffffffffc020106c:	8a2a                	mv	s4,a0
ffffffffc020106e:	38050663          	beqz	a0,ffffffffc02013fa <default_check+0x4d6>
    assert(alloc_page() == NULL);
ffffffffc0201072:	4505                	li	a0,1
ffffffffc0201074:	bf7ff0ef          	jal	ra,ffffffffc0200c6a <alloc_pages>
ffffffffc0201078:	36051163          	bnez	a0,ffffffffc02013da <default_check+0x4b6>
    free_page(p0);
ffffffffc020107c:	4585                	li	a1,1
ffffffffc020107e:	854e                	mv	a0,s3
ffffffffc0201080:	c2bff0ef          	jal	ra,ffffffffc0200caa <free_pages>
    assert(!list_empty(&free_list));
ffffffffc0201084:	641c                	ld	a5,8(s0)
ffffffffc0201086:	20878a63          	beq	a5,s0,ffffffffc020129a <default_check+0x376>
    assert((p = alloc_page()) == p0);
ffffffffc020108a:	4505                	li	a0,1
ffffffffc020108c:	bdfff0ef          	jal	ra,ffffffffc0200c6a <alloc_pages>
ffffffffc0201090:	30a99563          	bne	s3,a0,ffffffffc020139a <default_check+0x476>
    assert(alloc_page() == NULL);
ffffffffc0201094:	4505                	li	a0,1
ffffffffc0201096:	bd5ff0ef          	jal	ra,ffffffffc0200c6a <alloc_pages>
ffffffffc020109a:	2e051063          	bnez	a0,ffffffffc020137a <default_check+0x456>
    assert(nr_free == 0);
ffffffffc020109e:	481c                	lw	a5,16(s0)
ffffffffc02010a0:	2a079d63          	bnez	a5,ffffffffc020135a <default_check+0x436>
    free_page(p);
ffffffffc02010a4:	854e                	mv	a0,s3
ffffffffc02010a6:	4585                	li	a1,1
    free_list = free_list_store;
ffffffffc02010a8:	01843023          	sd	s8,0(s0)
ffffffffc02010ac:	01743423          	sd	s7,8(s0)
    nr_free = nr_free_store;
ffffffffc02010b0:	01642823          	sw	s6,16(s0)
    free_page(p);
ffffffffc02010b4:	bf7ff0ef          	jal	ra,ffffffffc0200caa <free_pages>
    free_page(p1);
ffffffffc02010b8:	4585                	li	a1,1
ffffffffc02010ba:	8556                	mv	a0,s5
ffffffffc02010bc:	befff0ef          	jal	ra,ffffffffc0200caa <free_pages>
    free_page(p2);
ffffffffc02010c0:	4585                	li	a1,1
ffffffffc02010c2:	8552                	mv	a0,s4
ffffffffc02010c4:	be7ff0ef          	jal	ra,ffffffffc0200caa <free_pages>

    basic_check();

    struct Page *p0 = alloc_pages(5), *p1, *p2;
ffffffffc02010c8:	4515                	li	a0,5
ffffffffc02010ca:	ba1ff0ef          	jal	ra,ffffffffc0200c6a <alloc_pages>
ffffffffc02010ce:	89aa                	mv	s3,a0
    assert(p0 != NULL);
ffffffffc02010d0:	26050563          	beqz	a0,ffffffffc020133a <default_check+0x416>
ffffffffc02010d4:	651c                	ld	a5,8(a0)
ffffffffc02010d6:	8385                	srli	a5,a5,0x1
    assert(!PageProperty(p0));
ffffffffc02010d8:	8b85                	andi	a5,a5,1
ffffffffc02010da:	54079063          	bnez	a5,ffffffffc020161a <default_check+0x6f6>

    list_entry_t free_list_store = free_list;
    list_init(&free_list);
    assert(list_empty(&free_list));
    assert(alloc_page() == NULL);
ffffffffc02010de:	4505                	li	a0,1
    list_entry_t free_list_store = free_list;
ffffffffc02010e0:	00043b03          	ld	s6,0(s0)
ffffffffc02010e4:	00843a83          	ld	s5,8(s0)
ffffffffc02010e8:	e000                	sd	s0,0(s0)
ffffffffc02010ea:	e400                	sd	s0,8(s0)
    assert(alloc_page() == NULL);
ffffffffc02010ec:	b7fff0ef          	jal	ra,ffffffffc0200c6a <alloc_pages>
ffffffffc02010f0:	50051563          	bnez	a0,ffffffffc02015fa <default_check+0x6d6>

    unsigned int nr_free_store = nr_free;
    nr_free = 0;

    free_pages(p0 + 2, 3);
ffffffffc02010f4:	05098a13          	addi	s4,s3,80
ffffffffc02010f8:	8552                	mv	a0,s4
ffffffffc02010fa:	458d                	li	a1,3
    unsigned int nr_free_store = nr_free;
ffffffffc02010fc:	01042b83          	lw	s7,16(s0)
    nr_free = 0;
ffffffffc0201100:	00006797          	auipc	a5,0x6
ffffffffc0201104:	f207ac23          	sw	zero,-200(a5) # ffffffffc0207038 <free_area+0x10>
    free_pages(p0 + 2, 3);
ffffffffc0201108:	ba3ff0ef          	jal	ra,ffffffffc0200caa <free_pages>
    assert(alloc_pages(4) == NULL);
ffffffffc020110c:	4511                	li	a0,4
ffffffffc020110e:	b5dff0ef          	jal	ra,ffffffffc0200c6a <alloc_pages>
ffffffffc0201112:	4c051463          	bnez	a0,ffffffffc02015da <default_check+0x6b6>
ffffffffc0201116:	0589b783          	ld	a5,88(s3)
ffffffffc020111a:	8385                	srli	a5,a5,0x1
    assert(PageProperty(p0 + 2) && p0[2].property == 3);
ffffffffc020111c:	8b85                	andi	a5,a5,1
ffffffffc020111e:	48078e63          	beqz	a5,ffffffffc02015ba <default_check+0x696>
ffffffffc0201122:	0609a703          	lw	a4,96(s3)
ffffffffc0201126:	478d                	li	a5,3
ffffffffc0201128:	48f71963          	bne	a4,a5,ffffffffc02015ba <default_check+0x696>
    assert((p1 = alloc_pages(3)) != NULL);
ffffffffc020112c:	450d                	li	a0,3
ffffffffc020112e:	b3dff0ef          	jal	ra,ffffffffc0200c6a <alloc_pages>
ffffffffc0201132:	8c2a                	mv	s8,a0
ffffffffc0201134:	46050363          	beqz	a0,ffffffffc020159a <default_check+0x676>
    assert(alloc_page() == NULL);
ffffffffc0201138:	4505                	li	a0,1
ffffffffc020113a:	b31ff0ef          	jal	ra,ffffffffc0200c6a <alloc_pages>
ffffffffc020113e:	42051e63          	bnez	a0,ffffffffc020157a <default_check+0x656>
    assert(p0 + 2 == p1);
ffffffffc0201142:	418a1c63          	bne	s4,s8,ffffffffc020155a <default_check+0x636>

    p2 = p0 + 1;
    free_page(p0);
ffffffffc0201146:	4585                	li	a1,1
ffffffffc0201148:	854e                	mv	a0,s3
ffffffffc020114a:	b61ff0ef          	jal	ra,ffffffffc0200caa <free_pages>
    free_pages(p1, 3);
ffffffffc020114e:	458d                	li	a1,3
ffffffffc0201150:	8552                	mv	a0,s4
ffffffffc0201152:	b59ff0ef          	jal	ra,ffffffffc0200caa <free_pages>
ffffffffc0201156:	0089b783          	ld	a5,8(s3)
    p2 = p0 + 1;
ffffffffc020115a:	02898c13          	addi	s8,s3,40
ffffffffc020115e:	8385                	srli	a5,a5,0x1
    assert(PageProperty(p0) && p0->property == 1);
ffffffffc0201160:	8b85                	andi	a5,a5,1
ffffffffc0201162:	3c078c63          	beqz	a5,ffffffffc020153a <default_check+0x616>
ffffffffc0201166:	0109a703          	lw	a4,16(s3)
ffffffffc020116a:	4785                	li	a5,1
ffffffffc020116c:	3cf71763          	bne	a4,a5,ffffffffc020153a <default_check+0x616>
ffffffffc0201170:	008a3783          	ld	a5,8(s4)
ffffffffc0201174:	8385                	srli	a5,a5,0x1
    assert(PageProperty(p1) && p1->property == 3);
ffffffffc0201176:	8b85                	andi	a5,a5,1
ffffffffc0201178:	3a078163          	beqz	a5,ffffffffc020151a <default_check+0x5f6>
ffffffffc020117c:	010a2703          	lw	a4,16(s4)
ffffffffc0201180:	478d                	li	a5,3
ffffffffc0201182:	38f71c63          	bne	a4,a5,ffffffffc020151a <default_check+0x5f6>

    assert((p0 = alloc_page()) == p2 - 1);
ffffffffc0201186:	4505                	li	a0,1
ffffffffc0201188:	ae3ff0ef          	jal	ra,ffffffffc0200c6a <alloc_pages>
ffffffffc020118c:	36a99763          	bne	s3,a0,ffffffffc02014fa <default_check+0x5d6>
    free_page(p0);
ffffffffc0201190:	4585                	li	a1,1
ffffffffc0201192:	b19ff0ef          	jal	ra,ffffffffc0200caa <free_pages>
    assert((p0 = alloc_pages(2)) == p2 + 1);
ffffffffc0201196:	4509                	li	a0,2
ffffffffc0201198:	ad3ff0ef          	jal	ra,ffffffffc0200c6a <alloc_pages>
ffffffffc020119c:	32aa1f63          	bne	s4,a0,ffffffffc02014da <default_check+0x5b6>

    free_pages(p0, 2);
ffffffffc02011a0:	4589                	li	a1,2
ffffffffc02011a2:	b09ff0ef          	jal	ra,ffffffffc0200caa <free_pages>
    free_page(p2);
ffffffffc02011a6:	4585                	li	a1,1
ffffffffc02011a8:	8562                	mv	a0,s8
ffffffffc02011aa:	b01ff0ef          	jal	ra,ffffffffc0200caa <free_pages>

    assert((p0 = alloc_pages(5)) != NULL);
ffffffffc02011ae:	4515                	li	a0,5
ffffffffc02011b0:	abbff0ef          	jal	ra,ffffffffc0200c6a <alloc_pages>
ffffffffc02011b4:	89aa                	mv	s3,a0
ffffffffc02011b6:	48050263          	beqz	a0,ffffffffc020163a <default_check+0x716>
    assert(alloc_page() == NULL);
ffffffffc02011ba:	4505                	li	a0,1
ffffffffc02011bc:	aafff0ef          	jal	ra,ffffffffc0200c6a <alloc_pages>
ffffffffc02011c0:	2c051d63          	bnez	a0,ffffffffc020149a <default_check+0x576>

    assert(nr_free == 0);
ffffffffc02011c4:	481c                	lw	a5,16(s0)
ffffffffc02011c6:	2a079a63          	bnez	a5,ffffffffc020147a <default_check+0x556>
    nr_free = nr_free_store;

    free_list = free_list_store;
    free_pages(p0, 5);
ffffffffc02011ca:	4595                	li	a1,5
ffffffffc02011cc:	854e                	mv	a0,s3
    nr_free = nr_free_store;
ffffffffc02011ce:	01742823          	sw	s7,16(s0)
    free_list = free_list_store;
ffffffffc02011d2:	01643023          	sd	s6,0(s0)
ffffffffc02011d6:	01543423          	sd	s5,8(s0)
    free_pages(p0, 5);
ffffffffc02011da:	ad1ff0ef          	jal	ra,ffffffffc0200caa <free_pages>
    return listelm->next;
ffffffffc02011de:	641c                	ld	a5,8(s0)

    le = &free_list;
    while ((le = list_next(le)) != &free_list) {
ffffffffc02011e0:	00878963          	beq	a5,s0,ffffffffc02011f2 <default_check+0x2ce>
        struct Page *p = le2page(le, page_link);
        count --, total -= p->property;
ffffffffc02011e4:	ff87a703          	lw	a4,-8(a5)
ffffffffc02011e8:	679c                	ld	a5,8(a5)
ffffffffc02011ea:	397d                	addiw	s2,s2,-1
ffffffffc02011ec:	9c99                	subw	s1,s1,a4
    while ((le = list_next(le)) != &free_list) {
ffffffffc02011ee:	fe879be3          	bne	a5,s0,ffffffffc02011e4 <default_check+0x2c0>
    }
    assert(count == 0);
ffffffffc02011f2:	26091463          	bnez	s2,ffffffffc020145a <default_check+0x536>
    assert(total == 0);
ffffffffc02011f6:	46049263          	bnez	s1,ffffffffc020165a <default_check+0x736>
}
ffffffffc02011fa:	60a6                	ld	ra,72(sp)
ffffffffc02011fc:	6406                	ld	s0,64(sp)
ffffffffc02011fe:	74e2                	ld	s1,56(sp)
ffffffffc0201200:	7942                	ld	s2,48(sp)
ffffffffc0201202:	79a2                	ld	s3,40(sp)
ffffffffc0201204:	7a02                	ld	s4,32(sp)
ffffffffc0201206:	6ae2                	ld	s5,24(sp)
ffffffffc0201208:	6b42                	ld	s6,16(sp)
ffffffffc020120a:	6ba2                	ld	s7,8(sp)
ffffffffc020120c:	6c02                	ld	s8,0(sp)
ffffffffc020120e:	6161                	addi	sp,sp,80
ffffffffc0201210:	8082                	ret
    while ((le = list_next(le)) != &free_list) {
ffffffffc0201212:	4981                	li	s3,0
    int count = 0, total = 0;
ffffffffc0201214:	4481                	li	s1,0
ffffffffc0201216:	4901                	li	s2,0
ffffffffc0201218:	b3b9                	j	ffffffffc0200f66 <default_check+0x42>
        assert(PageProperty(p));
ffffffffc020121a:	00001697          	auipc	a3,0x1
ffffffffc020121e:	7ee68693          	addi	a3,a3,2030 # ffffffffc0202a08 <commands+0x800>
ffffffffc0201222:	00001617          	auipc	a2,0x1
ffffffffc0201226:	7f660613          	addi	a2,a2,2038 # ffffffffc0202a18 <commands+0x810>
ffffffffc020122a:	0f000593          	li	a1,240
ffffffffc020122e:	00002517          	auipc	a0,0x2
ffffffffc0201232:	80250513          	addi	a0,a0,-2046 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201236:	f33fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(p0 != p1 && p0 != p2 && p1 != p2);
ffffffffc020123a:	00002697          	auipc	a3,0x2
ffffffffc020123e:	88e68693          	addi	a3,a3,-1906 # ffffffffc0202ac8 <commands+0x8c0>
ffffffffc0201242:	00001617          	auipc	a2,0x1
ffffffffc0201246:	7d660613          	addi	a2,a2,2006 # ffffffffc0202a18 <commands+0x810>
ffffffffc020124a:	0bd00593          	li	a1,189
ffffffffc020124e:	00001517          	auipc	a0,0x1
ffffffffc0201252:	7e250513          	addi	a0,a0,2018 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201256:	f13fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(page_ref(p0) == 0 && page_ref(p1) == 0 && page_ref(p2) == 0);
ffffffffc020125a:	00002697          	auipc	a3,0x2
ffffffffc020125e:	89668693          	addi	a3,a3,-1898 # ffffffffc0202af0 <commands+0x8e8>
ffffffffc0201262:	00001617          	auipc	a2,0x1
ffffffffc0201266:	7b660613          	addi	a2,a2,1974 # ffffffffc0202a18 <commands+0x810>
ffffffffc020126a:	0be00593          	li	a1,190
ffffffffc020126e:	00001517          	auipc	a0,0x1
ffffffffc0201272:	7c250513          	addi	a0,a0,1986 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201276:	ef3fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(page2pa(p0) < npage * PGSIZE);
ffffffffc020127a:	00002697          	auipc	a3,0x2
ffffffffc020127e:	8b668693          	addi	a3,a3,-1866 # ffffffffc0202b30 <commands+0x928>
ffffffffc0201282:	00001617          	auipc	a2,0x1
ffffffffc0201286:	79660613          	addi	a2,a2,1942 # ffffffffc0202a18 <commands+0x810>
ffffffffc020128a:	0c000593          	li	a1,192
ffffffffc020128e:	00001517          	auipc	a0,0x1
ffffffffc0201292:	7a250513          	addi	a0,a0,1954 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201296:	ed3fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(!list_empty(&free_list));
ffffffffc020129a:	00002697          	auipc	a3,0x2
ffffffffc020129e:	91e68693          	addi	a3,a3,-1762 # ffffffffc0202bb8 <commands+0x9b0>
ffffffffc02012a2:	00001617          	auipc	a2,0x1
ffffffffc02012a6:	77660613          	addi	a2,a2,1910 # ffffffffc0202a18 <commands+0x810>
ffffffffc02012aa:	0d900593          	li	a1,217
ffffffffc02012ae:	00001517          	auipc	a0,0x1
ffffffffc02012b2:	78250513          	addi	a0,a0,1922 # ffffffffc0202a30 <commands+0x828>
ffffffffc02012b6:	eb3fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert((p0 = alloc_page()) != NULL);
ffffffffc02012ba:	00001697          	auipc	a3,0x1
ffffffffc02012be:	7ae68693          	addi	a3,a3,1966 # ffffffffc0202a68 <commands+0x860>
ffffffffc02012c2:	00001617          	auipc	a2,0x1
ffffffffc02012c6:	75660613          	addi	a2,a2,1878 # ffffffffc0202a18 <commands+0x810>
ffffffffc02012ca:	0d200593          	li	a1,210
ffffffffc02012ce:	00001517          	auipc	a0,0x1
ffffffffc02012d2:	76250513          	addi	a0,a0,1890 # ffffffffc0202a30 <commands+0x828>
ffffffffc02012d6:	e93fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(nr_free == 3);
ffffffffc02012da:	00002697          	auipc	a3,0x2
ffffffffc02012de:	8ce68693          	addi	a3,a3,-1842 # ffffffffc0202ba8 <commands+0x9a0>
ffffffffc02012e2:	00001617          	auipc	a2,0x1
ffffffffc02012e6:	73660613          	addi	a2,a2,1846 # ffffffffc0202a18 <commands+0x810>
ffffffffc02012ea:	0d000593          	li	a1,208
ffffffffc02012ee:	00001517          	auipc	a0,0x1
ffffffffc02012f2:	74250513          	addi	a0,a0,1858 # ffffffffc0202a30 <commands+0x828>
ffffffffc02012f6:	e73fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(alloc_page() == NULL);
ffffffffc02012fa:	00002697          	auipc	a3,0x2
ffffffffc02012fe:	89668693          	addi	a3,a3,-1898 # ffffffffc0202b90 <commands+0x988>
ffffffffc0201302:	00001617          	auipc	a2,0x1
ffffffffc0201306:	71660613          	addi	a2,a2,1814 # ffffffffc0202a18 <commands+0x810>
ffffffffc020130a:	0cb00593          	li	a1,203
ffffffffc020130e:	00001517          	auipc	a0,0x1
ffffffffc0201312:	72250513          	addi	a0,a0,1826 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201316:	e53fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(page2pa(p2) < npage * PGSIZE);
ffffffffc020131a:	00002697          	auipc	a3,0x2
ffffffffc020131e:	85668693          	addi	a3,a3,-1962 # ffffffffc0202b70 <commands+0x968>
ffffffffc0201322:	00001617          	auipc	a2,0x1
ffffffffc0201326:	6f660613          	addi	a2,a2,1782 # ffffffffc0202a18 <commands+0x810>
ffffffffc020132a:	0c200593          	li	a1,194
ffffffffc020132e:	00001517          	auipc	a0,0x1
ffffffffc0201332:	70250513          	addi	a0,a0,1794 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201336:	e33fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(p0 != NULL);
ffffffffc020133a:	00002697          	auipc	a3,0x2
ffffffffc020133e:	8c668693          	addi	a3,a3,-1850 # ffffffffc0202c00 <commands+0x9f8>
ffffffffc0201342:	00001617          	auipc	a2,0x1
ffffffffc0201346:	6d660613          	addi	a2,a2,1750 # ffffffffc0202a18 <commands+0x810>
ffffffffc020134a:	0f800593          	li	a1,248
ffffffffc020134e:	00001517          	auipc	a0,0x1
ffffffffc0201352:	6e250513          	addi	a0,a0,1762 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201356:	e13fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(nr_free == 0);
ffffffffc020135a:	00002697          	auipc	a3,0x2
ffffffffc020135e:	89668693          	addi	a3,a3,-1898 # ffffffffc0202bf0 <commands+0x9e8>
ffffffffc0201362:	00001617          	auipc	a2,0x1
ffffffffc0201366:	6b660613          	addi	a2,a2,1718 # ffffffffc0202a18 <commands+0x810>
ffffffffc020136a:	0df00593          	li	a1,223
ffffffffc020136e:	00001517          	auipc	a0,0x1
ffffffffc0201372:	6c250513          	addi	a0,a0,1730 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201376:	df3fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(alloc_page() == NULL);
ffffffffc020137a:	00002697          	auipc	a3,0x2
ffffffffc020137e:	81668693          	addi	a3,a3,-2026 # ffffffffc0202b90 <commands+0x988>
ffffffffc0201382:	00001617          	auipc	a2,0x1
ffffffffc0201386:	69660613          	addi	a2,a2,1686 # ffffffffc0202a18 <commands+0x810>
ffffffffc020138a:	0dd00593          	li	a1,221
ffffffffc020138e:	00001517          	auipc	a0,0x1
ffffffffc0201392:	6a250513          	addi	a0,a0,1698 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201396:	dd3fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert((p = alloc_page()) == p0);
ffffffffc020139a:	00002697          	auipc	a3,0x2
ffffffffc020139e:	83668693          	addi	a3,a3,-1994 # ffffffffc0202bd0 <commands+0x9c8>
ffffffffc02013a2:	00001617          	auipc	a2,0x1
ffffffffc02013a6:	67660613          	addi	a2,a2,1654 # ffffffffc0202a18 <commands+0x810>
ffffffffc02013aa:	0dc00593          	li	a1,220
ffffffffc02013ae:	00001517          	auipc	a0,0x1
ffffffffc02013b2:	68250513          	addi	a0,a0,1666 # ffffffffc0202a30 <commands+0x828>
ffffffffc02013b6:	db3fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert((p0 = alloc_page()) != NULL);
ffffffffc02013ba:	00001697          	auipc	a3,0x1
ffffffffc02013be:	6ae68693          	addi	a3,a3,1710 # ffffffffc0202a68 <commands+0x860>
ffffffffc02013c2:	00001617          	auipc	a2,0x1
ffffffffc02013c6:	65660613          	addi	a2,a2,1622 # ffffffffc0202a18 <commands+0x810>
ffffffffc02013ca:	0b900593          	li	a1,185
ffffffffc02013ce:	00001517          	auipc	a0,0x1
ffffffffc02013d2:	66250513          	addi	a0,a0,1634 # ffffffffc0202a30 <commands+0x828>
ffffffffc02013d6:	d93fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(alloc_page() == NULL);
ffffffffc02013da:	00001697          	auipc	a3,0x1
ffffffffc02013de:	7b668693          	addi	a3,a3,1974 # ffffffffc0202b90 <commands+0x988>
ffffffffc02013e2:	00001617          	auipc	a2,0x1
ffffffffc02013e6:	63660613          	addi	a2,a2,1590 # ffffffffc0202a18 <commands+0x810>
ffffffffc02013ea:	0d600593          	li	a1,214
ffffffffc02013ee:	00001517          	auipc	a0,0x1
ffffffffc02013f2:	64250513          	addi	a0,a0,1602 # ffffffffc0202a30 <commands+0x828>
ffffffffc02013f6:	d73fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert((p2 = alloc_page()) != NULL);
ffffffffc02013fa:	00001697          	auipc	a3,0x1
ffffffffc02013fe:	6ae68693          	addi	a3,a3,1710 # ffffffffc0202aa8 <commands+0x8a0>
ffffffffc0201402:	00001617          	auipc	a2,0x1
ffffffffc0201406:	61660613          	addi	a2,a2,1558 # ffffffffc0202a18 <commands+0x810>
ffffffffc020140a:	0d400593          	li	a1,212
ffffffffc020140e:	00001517          	auipc	a0,0x1
ffffffffc0201412:	62250513          	addi	a0,a0,1570 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201416:	d53fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert((p1 = alloc_page()) != NULL);
ffffffffc020141a:	00001697          	auipc	a3,0x1
ffffffffc020141e:	66e68693          	addi	a3,a3,1646 # ffffffffc0202a88 <commands+0x880>
ffffffffc0201422:	00001617          	auipc	a2,0x1
ffffffffc0201426:	5f660613          	addi	a2,a2,1526 # ffffffffc0202a18 <commands+0x810>
ffffffffc020142a:	0d300593          	li	a1,211
ffffffffc020142e:	00001517          	auipc	a0,0x1
ffffffffc0201432:	60250513          	addi	a0,a0,1538 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201436:	d33fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert((p2 = alloc_page()) != NULL);
ffffffffc020143a:	00001697          	auipc	a3,0x1
ffffffffc020143e:	66e68693          	addi	a3,a3,1646 # ffffffffc0202aa8 <commands+0x8a0>
ffffffffc0201442:	00001617          	auipc	a2,0x1
ffffffffc0201446:	5d660613          	addi	a2,a2,1494 # ffffffffc0202a18 <commands+0x810>
ffffffffc020144a:	0bb00593          	li	a1,187
ffffffffc020144e:	00001517          	auipc	a0,0x1
ffffffffc0201452:	5e250513          	addi	a0,a0,1506 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201456:	d13fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(count == 0);
ffffffffc020145a:	00002697          	auipc	a3,0x2
ffffffffc020145e:	8f668693          	addi	a3,a3,-1802 # ffffffffc0202d50 <commands+0xb48>
ffffffffc0201462:	00001617          	auipc	a2,0x1
ffffffffc0201466:	5b660613          	addi	a2,a2,1462 # ffffffffc0202a18 <commands+0x810>
ffffffffc020146a:	12500593          	li	a1,293
ffffffffc020146e:	00001517          	auipc	a0,0x1
ffffffffc0201472:	5c250513          	addi	a0,a0,1474 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201476:	cf3fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(nr_free == 0);
ffffffffc020147a:	00001697          	auipc	a3,0x1
ffffffffc020147e:	77668693          	addi	a3,a3,1910 # ffffffffc0202bf0 <commands+0x9e8>
ffffffffc0201482:	00001617          	auipc	a2,0x1
ffffffffc0201486:	59660613          	addi	a2,a2,1430 # ffffffffc0202a18 <commands+0x810>
ffffffffc020148a:	11a00593          	li	a1,282
ffffffffc020148e:	00001517          	auipc	a0,0x1
ffffffffc0201492:	5a250513          	addi	a0,a0,1442 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201496:	cd3fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(alloc_page() == NULL);
ffffffffc020149a:	00001697          	auipc	a3,0x1
ffffffffc020149e:	6f668693          	addi	a3,a3,1782 # ffffffffc0202b90 <commands+0x988>
ffffffffc02014a2:	00001617          	auipc	a2,0x1
ffffffffc02014a6:	57660613          	addi	a2,a2,1398 # ffffffffc0202a18 <commands+0x810>
ffffffffc02014aa:	11800593          	li	a1,280
ffffffffc02014ae:	00001517          	auipc	a0,0x1
ffffffffc02014b2:	58250513          	addi	a0,a0,1410 # ffffffffc0202a30 <commands+0x828>
ffffffffc02014b6:	cb3fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(page2pa(p1) < npage * PGSIZE);
ffffffffc02014ba:	00001697          	auipc	a3,0x1
ffffffffc02014be:	69668693          	addi	a3,a3,1686 # ffffffffc0202b50 <commands+0x948>
ffffffffc02014c2:	00001617          	auipc	a2,0x1
ffffffffc02014c6:	55660613          	addi	a2,a2,1366 # ffffffffc0202a18 <commands+0x810>
ffffffffc02014ca:	0c100593          	li	a1,193
ffffffffc02014ce:	00001517          	auipc	a0,0x1
ffffffffc02014d2:	56250513          	addi	a0,a0,1378 # ffffffffc0202a30 <commands+0x828>
ffffffffc02014d6:	c93fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert((p0 = alloc_pages(2)) == p2 + 1);
ffffffffc02014da:	00002697          	auipc	a3,0x2
ffffffffc02014de:	83668693          	addi	a3,a3,-1994 # ffffffffc0202d10 <commands+0xb08>
ffffffffc02014e2:	00001617          	auipc	a2,0x1
ffffffffc02014e6:	53660613          	addi	a2,a2,1334 # ffffffffc0202a18 <commands+0x810>
ffffffffc02014ea:	11200593          	li	a1,274
ffffffffc02014ee:	00001517          	auipc	a0,0x1
ffffffffc02014f2:	54250513          	addi	a0,a0,1346 # ffffffffc0202a30 <commands+0x828>
ffffffffc02014f6:	c73fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert((p0 = alloc_page()) == p2 - 1);
ffffffffc02014fa:	00001697          	auipc	a3,0x1
ffffffffc02014fe:	7f668693          	addi	a3,a3,2038 # ffffffffc0202cf0 <commands+0xae8>
ffffffffc0201502:	00001617          	auipc	a2,0x1
ffffffffc0201506:	51660613          	addi	a2,a2,1302 # ffffffffc0202a18 <commands+0x810>
ffffffffc020150a:	11000593          	li	a1,272
ffffffffc020150e:	00001517          	auipc	a0,0x1
ffffffffc0201512:	52250513          	addi	a0,a0,1314 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201516:	c53fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(PageProperty(p1) && p1->property == 3);
ffffffffc020151a:	00001697          	auipc	a3,0x1
ffffffffc020151e:	7ae68693          	addi	a3,a3,1966 # ffffffffc0202cc8 <commands+0xac0>
ffffffffc0201522:	00001617          	auipc	a2,0x1
ffffffffc0201526:	4f660613          	addi	a2,a2,1270 # ffffffffc0202a18 <commands+0x810>
ffffffffc020152a:	10e00593          	li	a1,270
ffffffffc020152e:	00001517          	auipc	a0,0x1
ffffffffc0201532:	50250513          	addi	a0,a0,1282 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201536:	c33fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(PageProperty(p0) && p0->property == 1);
ffffffffc020153a:	00001697          	auipc	a3,0x1
ffffffffc020153e:	76668693          	addi	a3,a3,1894 # ffffffffc0202ca0 <commands+0xa98>
ffffffffc0201542:	00001617          	auipc	a2,0x1
ffffffffc0201546:	4d660613          	addi	a2,a2,1238 # ffffffffc0202a18 <commands+0x810>
ffffffffc020154a:	10d00593          	li	a1,269
ffffffffc020154e:	00001517          	auipc	a0,0x1
ffffffffc0201552:	4e250513          	addi	a0,a0,1250 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201556:	c13fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(p0 + 2 == p1);
ffffffffc020155a:	00001697          	auipc	a3,0x1
ffffffffc020155e:	73668693          	addi	a3,a3,1846 # ffffffffc0202c90 <commands+0xa88>
ffffffffc0201562:	00001617          	auipc	a2,0x1
ffffffffc0201566:	4b660613          	addi	a2,a2,1206 # ffffffffc0202a18 <commands+0x810>
ffffffffc020156a:	10800593          	li	a1,264
ffffffffc020156e:	00001517          	auipc	a0,0x1
ffffffffc0201572:	4c250513          	addi	a0,a0,1218 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201576:	bf3fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(alloc_page() == NULL);
ffffffffc020157a:	00001697          	auipc	a3,0x1
ffffffffc020157e:	61668693          	addi	a3,a3,1558 # ffffffffc0202b90 <commands+0x988>
ffffffffc0201582:	00001617          	auipc	a2,0x1
ffffffffc0201586:	49660613          	addi	a2,a2,1174 # ffffffffc0202a18 <commands+0x810>
ffffffffc020158a:	10700593          	li	a1,263
ffffffffc020158e:	00001517          	auipc	a0,0x1
ffffffffc0201592:	4a250513          	addi	a0,a0,1186 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201596:	bd3fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert((p1 = alloc_pages(3)) != NULL);
ffffffffc020159a:	00001697          	auipc	a3,0x1
ffffffffc020159e:	6d668693          	addi	a3,a3,1750 # ffffffffc0202c70 <commands+0xa68>
ffffffffc02015a2:	00001617          	auipc	a2,0x1
ffffffffc02015a6:	47660613          	addi	a2,a2,1142 # ffffffffc0202a18 <commands+0x810>
ffffffffc02015aa:	10600593          	li	a1,262
ffffffffc02015ae:	00001517          	auipc	a0,0x1
ffffffffc02015b2:	48250513          	addi	a0,a0,1154 # ffffffffc0202a30 <commands+0x828>
ffffffffc02015b6:	bb3fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(PageProperty(p0 + 2) && p0[2].property == 3);
ffffffffc02015ba:	00001697          	auipc	a3,0x1
ffffffffc02015be:	68668693          	addi	a3,a3,1670 # ffffffffc0202c40 <commands+0xa38>
ffffffffc02015c2:	00001617          	auipc	a2,0x1
ffffffffc02015c6:	45660613          	addi	a2,a2,1110 # ffffffffc0202a18 <commands+0x810>
ffffffffc02015ca:	10500593          	li	a1,261
ffffffffc02015ce:	00001517          	auipc	a0,0x1
ffffffffc02015d2:	46250513          	addi	a0,a0,1122 # ffffffffc0202a30 <commands+0x828>
ffffffffc02015d6:	b93fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(alloc_pages(4) == NULL);
ffffffffc02015da:	00001697          	auipc	a3,0x1
ffffffffc02015de:	64e68693          	addi	a3,a3,1614 # ffffffffc0202c28 <commands+0xa20>
ffffffffc02015e2:	00001617          	auipc	a2,0x1
ffffffffc02015e6:	43660613          	addi	a2,a2,1078 # ffffffffc0202a18 <commands+0x810>
ffffffffc02015ea:	10400593          	li	a1,260
ffffffffc02015ee:	00001517          	auipc	a0,0x1
ffffffffc02015f2:	44250513          	addi	a0,a0,1090 # ffffffffc0202a30 <commands+0x828>
ffffffffc02015f6:	b73fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(alloc_page() == NULL);
ffffffffc02015fa:	00001697          	auipc	a3,0x1
ffffffffc02015fe:	59668693          	addi	a3,a3,1430 # ffffffffc0202b90 <commands+0x988>
ffffffffc0201602:	00001617          	auipc	a2,0x1
ffffffffc0201606:	41660613          	addi	a2,a2,1046 # ffffffffc0202a18 <commands+0x810>
ffffffffc020160a:	0fe00593          	li	a1,254
ffffffffc020160e:	00001517          	auipc	a0,0x1
ffffffffc0201612:	42250513          	addi	a0,a0,1058 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201616:	b53fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(!PageProperty(p0));
ffffffffc020161a:	00001697          	auipc	a3,0x1
ffffffffc020161e:	5f668693          	addi	a3,a3,1526 # ffffffffc0202c10 <commands+0xa08>
ffffffffc0201622:	00001617          	auipc	a2,0x1
ffffffffc0201626:	3f660613          	addi	a2,a2,1014 # ffffffffc0202a18 <commands+0x810>
ffffffffc020162a:	0f900593          	li	a1,249
ffffffffc020162e:	00001517          	auipc	a0,0x1
ffffffffc0201632:	40250513          	addi	a0,a0,1026 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201636:	b33fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert((p0 = alloc_pages(5)) != NULL);
ffffffffc020163a:	00001697          	auipc	a3,0x1
ffffffffc020163e:	6f668693          	addi	a3,a3,1782 # ffffffffc0202d30 <commands+0xb28>
ffffffffc0201642:	00001617          	auipc	a2,0x1
ffffffffc0201646:	3d660613          	addi	a2,a2,982 # ffffffffc0202a18 <commands+0x810>
ffffffffc020164a:	11700593          	li	a1,279
ffffffffc020164e:	00001517          	auipc	a0,0x1
ffffffffc0201652:	3e250513          	addi	a0,a0,994 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201656:	b13fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(total == 0);
ffffffffc020165a:	00001697          	auipc	a3,0x1
ffffffffc020165e:	70668693          	addi	a3,a3,1798 # ffffffffc0202d60 <commands+0xb58>
ffffffffc0201662:	00001617          	auipc	a2,0x1
ffffffffc0201666:	3b660613          	addi	a2,a2,950 # ffffffffc0202a18 <commands+0x810>
ffffffffc020166a:	12600593          	li	a1,294
ffffffffc020166e:	00001517          	auipc	a0,0x1
ffffffffc0201672:	3c250513          	addi	a0,a0,962 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201676:	af3fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(total == nr_free_pages());
ffffffffc020167a:	00001697          	auipc	a3,0x1
ffffffffc020167e:	3ce68693          	addi	a3,a3,974 # ffffffffc0202a48 <commands+0x840>
ffffffffc0201682:	00001617          	auipc	a2,0x1
ffffffffc0201686:	39660613          	addi	a2,a2,918 # ffffffffc0202a18 <commands+0x810>
ffffffffc020168a:	0f300593          	li	a1,243
ffffffffc020168e:	00001517          	auipc	a0,0x1
ffffffffc0201692:	3a250513          	addi	a0,a0,930 # ffffffffc0202a30 <commands+0x828>
ffffffffc0201696:	ad3fe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert((p1 = alloc_page()) != NULL);
ffffffffc020169a:	00001697          	auipc	a3,0x1
ffffffffc020169e:	3ee68693          	addi	a3,a3,1006 # ffffffffc0202a88 <commands+0x880>
ffffffffc02016a2:	00001617          	auipc	a2,0x1
ffffffffc02016a6:	37660613          	addi	a2,a2,886 # ffffffffc0202a18 <commands+0x810>
ffffffffc02016aa:	0ba00593          	li	a1,186
ffffffffc02016ae:	00001517          	auipc	a0,0x1
ffffffffc02016b2:	38250513          	addi	a0,a0,898 # ffffffffc0202a30 <commands+0x828>
ffffffffc02016b6:	ab3fe0ef          	jal	ra,ffffffffc0200168 <__panic>

ffffffffc02016ba <default_free_pages>:
default_free_pages(struct Page *base, size_t n) {
ffffffffc02016ba:	1141                	addi	sp,sp,-16
ffffffffc02016bc:	e406                	sd	ra,8(sp)
    assert(n > 0);
ffffffffc02016be:	14058a63          	beqz	a1,ffffffffc0201812 <default_free_pages+0x158>
    for (; p != base + n; p ++) {
ffffffffc02016c2:	00259693          	slli	a3,a1,0x2
ffffffffc02016c6:	96ae                	add	a3,a3,a1
ffffffffc02016c8:	068e                	slli	a3,a3,0x3
ffffffffc02016ca:	96aa                	add	a3,a3,a0
ffffffffc02016cc:	87aa                	mv	a5,a0
ffffffffc02016ce:	02d50263          	beq	a0,a3,ffffffffc02016f2 <default_free_pages+0x38>
ffffffffc02016d2:	6798                	ld	a4,8(a5)
        assert(!PageReserved(p) && !PageProperty(p));
ffffffffc02016d4:	8b05                	andi	a4,a4,1
ffffffffc02016d6:	10071e63          	bnez	a4,ffffffffc02017f2 <default_free_pages+0x138>
ffffffffc02016da:	6798                	ld	a4,8(a5)
ffffffffc02016dc:	8b09                	andi	a4,a4,2
ffffffffc02016de:	10071a63          	bnez	a4,ffffffffc02017f2 <default_free_pages+0x138>
        p->flags = 0;
ffffffffc02016e2:	0007b423          	sd	zero,8(a5)
static inline void set_page_ref(struct Page *page, int val) { page->ref = val; }
ffffffffc02016e6:	0007a023          	sw	zero,0(a5)
    for (; p != base + n; p ++) {
ffffffffc02016ea:	02878793          	addi	a5,a5,40
ffffffffc02016ee:	fed792e3          	bne	a5,a3,ffffffffc02016d2 <default_free_pages+0x18>
    base->property = n;
ffffffffc02016f2:	2581                	sext.w	a1,a1
ffffffffc02016f4:	c90c                	sw	a1,16(a0)
    SetPageProperty(base);
ffffffffc02016f6:	00850893          	addi	a7,a0,8
    __op_bit(or, __NOP, nr, ((volatile unsigned long *)addr));
ffffffffc02016fa:	4789                	li	a5,2
ffffffffc02016fc:	40f8b02f          	amoor.d	zero,a5,(a7)
    nr_free += n;
ffffffffc0201700:	00006697          	auipc	a3,0x6
ffffffffc0201704:	92868693          	addi	a3,a3,-1752 # ffffffffc0207028 <free_area>
ffffffffc0201708:	4a98                	lw	a4,16(a3)
    return list->next == list;
ffffffffc020170a:	669c                	ld	a5,8(a3)
ffffffffc020170c:	01850613          	addi	a2,a0,24
ffffffffc0201710:	9db9                	addw	a1,a1,a4
ffffffffc0201712:	ca8c                	sw	a1,16(a3)
    if (list_empty(&free_list)) {
ffffffffc0201714:	0ad78863          	beq	a5,a3,ffffffffc02017c4 <default_free_pages+0x10a>
            struct Page* page = le2page(le, page_link);
ffffffffc0201718:	fe878713          	addi	a4,a5,-24
ffffffffc020171c:	0006b803          	ld	a6,0(a3)
    if (list_empty(&free_list)) {
ffffffffc0201720:	4581                	li	a1,0
            if (base < page) {
ffffffffc0201722:	00e56a63          	bltu	a0,a4,ffffffffc0201736 <default_free_pages+0x7c>
    return listelm->next;
ffffffffc0201726:	6798                	ld	a4,8(a5)
            } else if (list_next(le) == &free_list) {
ffffffffc0201728:	06d70263          	beq	a4,a3,ffffffffc020178c <default_free_pages+0xd2>
    for (; p != base + n; p ++) {
ffffffffc020172c:	87ba                	mv	a5,a4
            struct Page* page = le2page(le, page_link);
ffffffffc020172e:	fe878713          	addi	a4,a5,-24
            if (base < page) {
ffffffffc0201732:	fee57ae3          	bgeu	a0,a4,ffffffffc0201726 <default_free_pages+0x6c>
ffffffffc0201736:	c199                	beqz	a1,ffffffffc020173c <default_free_pages+0x82>
ffffffffc0201738:	0106b023          	sd	a6,0(a3)
    __list_add(elm, listelm->prev, listelm);
ffffffffc020173c:	6398                	ld	a4,0(a5)
 * This is only for internal list manipulation where we know
 * the prev/next entries already!
 * */
static inline void
__list_add(list_entry_t *elm, list_entry_t *prev, list_entry_t *next) {
    prev->next = next->prev = elm;
ffffffffc020173e:	e390                	sd	a2,0(a5)
ffffffffc0201740:	e710                	sd	a2,8(a4)
    elm->next = next;
ffffffffc0201742:	f11c                	sd	a5,32(a0)
    elm->prev = prev;
ffffffffc0201744:	ed18                	sd	a4,24(a0)
    if (le != &free_list) {
ffffffffc0201746:	02d70063          	beq	a4,a3,ffffffffc0201766 <default_free_pages+0xac>
        if (p + p->property == base) {
ffffffffc020174a:	ff872803          	lw	a6,-8(a4) # fffffffffff7fff8 <end+0x3fd78b58>
        p = le2page(le, page_link);
ffffffffc020174e:	fe870593          	addi	a1,a4,-24
        if (p + p->property == base) {
ffffffffc0201752:	02081613          	slli	a2,a6,0x20
ffffffffc0201756:	9201                	srli	a2,a2,0x20
ffffffffc0201758:	00261793          	slli	a5,a2,0x2
ffffffffc020175c:	97b2                	add	a5,a5,a2
ffffffffc020175e:	078e                	slli	a5,a5,0x3
ffffffffc0201760:	97ae                	add	a5,a5,a1
ffffffffc0201762:	02f50f63          	beq	a0,a5,ffffffffc02017a0 <default_free_pages+0xe6>
ffffffffc0201766:	7118                	ld	a4,32(a0)
    if (le != &free_list) {
ffffffffc0201768:	00d70f63          	beq	a4,a3,ffffffffc0201786 <default_free_pages+0xcc>
        if (base + base->property == p) {
ffffffffc020176c:	490c                	lw	a1,16(a0)
        p = le2page(le, page_link);
ffffffffc020176e:	fe870693          	addi	a3,a4,-24
        if (base + base->property == p) {
ffffffffc0201772:	02059613          	slli	a2,a1,0x20
ffffffffc0201776:	9201                	srli	a2,a2,0x20
ffffffffc0201778:	00261793          	slli	a5,a2,0x2
ffffffffc020177c:	97b2                	add	a5,a5,a2
ffffffffc020177e:	078e                	slli	a5,a5,0x3
ffffffffc0201780:	97aa                	add	a5,a5,a0
ffffffffc0201782:	04f68863          	beq	a3,a5,ffffffffc02017d2 <default_free_pages+0x118>
}
ffffffffc0201786:	60a2                	ld	ra,8(sp)
ffffffffc0201788:	0141                	addi	sp,sp,16
ffffffffc020178a:	8082                	ret
    prev->next = next->prev = elm;
ffffffffc020178c:	e790                	sd	a2,8(a5)
    elm->next = next;
ffffffffc020178e:	f114                	sd	a3,32(a0)
    return listelm->next;
ffffffffc0201790:	6798                	ld	a4,8(a5)
    elm->prev = prev;
ffffffffc0201792:	ed1c                	sd	a5,24(a0)
        while ((le = list_next(le)) != &free_list) {
ffffffffc0201794:	02d70563          	beq	a4,a3,ffffffffc02017be <default_free_pages+0x104>
    prev->next = next->prev = elm;
ffffffffc0201798:	8832                	mv	a6,a2
ffffffffc020179a:	4585                	li	a1,1
    for (; p != base + n; p ++) {
ffffffffc020179c:	87ba                	mv	a5,a4
ffffffffc020179e:	bf41                	j	ffffffffc020172e <default_free_pages+0x74>
            p->property += base->property;
ffffffffc02017a0:	491c                	lw	a5,16(a0)
ffffffffc02017a2:	0107883b          	addw	a6,a5,a6
ffffffffc02017a6:	ff072c23          	sw	a6,-8(a4)
    __op_bit(and, __NOT, nr, ((volatile unsigned long *)addr));
ffffffffc02017aa:	57f5                	li	a5,-3
ffffffffc02017ac:	60f8b02f          	amoand.d	zero,a5,(a7)
    __list_del(listelm->prev, listelm->next);
ffffffffc02017b0:	6d10                	ld	a2,24(a0)
ffffffffc02017b2:	711c                	ld	a5,32(a0)
            base = p;
ffffffffc02017b4:	852e                	mv	a0,a1
 * This is only for internal list manipulation where we know
 * the prev/next entries already!
 * */
static inline void
__list_del(list_entry_t *prev, list_entry_t *next) {
    prev->next = next;
ffffffffc02017b6:	e61c                	sd	a5,8(a2)
    next->prev = prev;
ffffffffc02017b8:	6718                	ld	a4,8(a4)
ffffffffc02017ba:	e390                	sd	a2,0(a5)
ffffffffc02017bc:	b775                	j	ffffffffc0201768 <default_free_pages+0xae>
ffffffffc02017be:	e290                	sd	a2,0(a3)
        while ((le = list_next(le)) != &free_list) {
ffffffffc02017c0:	873e                	mv	a4,a5
ffffffffc02017c2:	b761                	j	ffffffffc020174a <default_free_pages+0x90>
}
ffffffffc02017c4:	60a2                	ld	ra,8(sp)
    prev->next = next->prev = elm;
ffffffffc02017c6:	e390                	sd	a2,0(a5)
ffffffffc02017c8:	e790                	sd	a2,8(a5)
    elm->next = next;
ffffffffc02017ca:	f11c                	sd	a5,32(a0)
    elm->prev = prev;
ffffffffc02017cc:	ed1c                	sd	a5,24(a0)
ffffffffc02017ce:	0141                	addi	sp,sp,16
ffffffffc02017d0:	8082                	ret
            base->property += p->property;
ffffffffc02017d2:	ff872783          	lw	a5,-8(a4)
ffffffffc02017d6:	ff070693          	addi	a3,a4,-16
ffffffffc02017da:	9dbd                	addw	a1,a1,a5
ffffffffc02017dc:	c90c                	sw	a1,16(a0)
ffffffffc02017de:	57f5                	li	a5,-3
ffffffffc02017e0:	60f6b02f          	amoand.d	zero,a5,(a3)
    __list_del(listelm->prev, listelm->next);
ffffffffc02017e4:	6314                	ld	a3,0(a4)
ffffffffc02017e6:	671c                	ld	a5,8(a4)
}
ffffffffc02017e8:	60a2                	ld	ra,8(sp)
    prev->next = next;
ffffffffc02017ea:	e69c                	sd	a5,8(a3)
    next->prev = prev;
ffffffffc02017ec:	e394                	sd	a3,0(a5)
ffffffffc02017ee:	0141                	addi	sp,sp,16
ffffffffc02017f0:	8082                	ret
        assert(!PageReserved(p) && !PageProperty(p));
ffffffffc02017f2:	00001697          	auipc	a3,0x1
ffffffffc02017f6:	58668693          	addi	a3,a3,1414 # ffffffffc0202d78 <commands+0xb70>
ffffffffc02017fa:	00001617          	auipc	a2,0x1
ffffffffc02017fe:	21e60613          	addi	a2,a2,542 # ffffffffc0202a18 <commands+0x810>
ffffffffc0201802:	08300593          	li	a1,131
ffffffffc0201806:	00001517          	auipc	a0,0x1
ffffffffc020180a:	22a50513          	addi	a0,a0,554 # ffffffffc0202a30 <commands+0x828>
ffffffffc020180e:	95bfe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(n > 0);
ffffffffc0201812:	00001697          	auipc	a3,0x1
ffffffffc0201816:	55e68693          	addi	a3,a3,1374 # ffffffffc0202d70 <commands+0xb68>
ffffffffc020181a:	00001617          	auipc	a2,0x1
ffffffffc020181e:	1fe60613          	addi	a2,a2,510 # ffffffffc0202a18 <commands+0x810>
ffffffffc0201822:	08000593          	li	a1,128
ffffffffc0201826:	00001517          	auipc	a0,0x1
ffffffffc020182a:	20a50513          	addi	a0,a0,522 # ffffffffc0202a30 <commands+0x828>
ffffffffc020182e:	93bfe0ef          	jal	ra,ffffffffc0200168 <__panic>

ffffffffc0201832 <default_alloc_pages>:
    assert(n > 0);
ffffffffc0201832:	c959                	beqz	a0,ffffffffc02018c8 <default_alloc_pages+0x96>
    if (n > nr_free) {
ffffffffc0201834:	00005597          	auipc	a1,0x5
ffffffffc0201838:	7f458593          	addi	a1,a1,2036 # ffffffffc0207028 <free_area>
ffffffffc020183c:	0105a803          	lw	a6,16(a1)
ffffffffc0201840:	862a                	mv	a2,a0
ffffffffc0201842:	02081793          	slli	a5,a6,0x20
ffffffffc0201846:	9381                	srli	a5,a5,0x20
ffffffffc0201848:	00a7ee63          	bltu	a5,a0,ffffffffc0201864 <default_alloc_pages+0x32>
    list_entry_t *le = &free_list;
ffffffffc020184c:	87ae                	mv	a5,a1
ffffffffc020184e:	a801                	j	ffffffffc020185e <default_alloc_pages+0x2c>
        if (p->property >= n) {
ffffffffc0201850:	ff87a703          	lw	a4,-8(a5)
ffffffffc0201854:	02071693          	slli	a3,a4,0x20
ffffffffc0201858:	9281                	srli	a3,a3,0x20
ffffffffc020185a:	00c6f763          	bgeu	a3,a2,ffffffffc0201868 <default_alloc_pages+0x36>
    return listelm->next;
ffffffffc020185e:	679c                	ld	a5,8(a5)
    while ((le = list_next(le)) != &free_list) {
ffffffffc0201860:	feb798e3          	bne	a5,a1,ffffffffc0201850 <default_alloc_pages+0x1e>
        return NULL;
ffffffffc0201864:	4501                	li	a0,0
}
ffffffffc0201866:	8082                	ret
    return listelm->prev;
ffffffffc0201868:	0007b883          	ld	a7,0(a5)
    __list_del(listelm->prev, listelm->next);
ffffffffc020186c:	0087b303          	ld	t1,8(a5)
        struct Page *p = le2page(le, page_link);
ffffffffc0201870:	fe878513          	addi	a0,a5,-24
    prev->next = next;
ffffffffc0201874:	00060e1b          	sext.w	t3,a2
ffffffffc0201878:	0068b423          	sd	t1,8(a7)
    next->prev = prev;
ffffffffc020187c:	01133023          	sd	a7,0(t1)
        if (page->property > n) {
ffffffffc0201880:	02d67b63          	bgeu	a2,a3,ffffffffc02018b6 <default_alloc_pages+0x84>
            struct Page *p = page + n;
ffffffffc0201884:	00261693          	slli	a3,a2,0x2
ffffffffc0201888:	96b2                	add	a3,a3,a2
ffffffffc020188a:	068e                	slli	a3,a3,0x3
ffffffffc020188c:	96aa                	add	a3,a3,a0
            p->property = page->property - n;
ffffffffc020188e:	41c7073b          	subw	a4,a4,t3
ffffffffc0201892:	ca98                	sw	a4,16(a3)
    __op_bit(or, __NOP, nr, ((volatile unsigned long *)addr));
ffffffffc0201894:	00868613          	addi	a2,a3,8
ffffffffc0201898:	4709                	li	a4,2
ffffffffc020189a:	40e6302f          	amoor.d	zero,a4,(a2)
    __list_add(elm, listelm, listelm->next);
ffffffffc020189e:	0088b703          	ld	a4,8(a7)
            list_add(prev, &(p->page_link));
ffffffffc02018a2:	01868613          	addi	a2,a3,24
    prev->next = next->prev = elm;
ffffffffc02018a6:	0105a803          	lw	a6,16(a1)
ffffffffc02018aa:	e310                	sd	a2,0(a4)
ffffffffc02018ac:	00c8b423          	sd	a2,8(a7)
    elm->next = next;
ffffffffc02018b0:	f298                	sd	a4,32(a3)
    elm->prev = prev;
ffffffffc02018b2:	0116bc23          	sd	a7,24(a3)
        nr_free -= n;
ffffffffc02018b6:	41c8083b          	subw	a6,a6,t3
ffffffffc02018ba:	0105a823          	sw	a6,16(a1)
    __op_bit(and, __NOT, nr, ((volatile unsigned long *)addr));
ffffffffc02018be:	5775                	li	a4,-3
ffffffffc02018c0:	17c1                	addi	a5,a5,-16
ffffffffc02018c2:	60e7b02f          	amoand.d	zero,a4,(a5)
}
ffffffffc02018c6:	8082                	ret
default_alloc_pages(size_t n) {
ffffffffc02018c8:	1141                	addi	sp,sp,-16
    assert(n > 0);
ffffffffc02018ca:	00001697          	auipc	a3,0x1
ffffffffc02018ce:	4a668693          	addi	a3,a3,1190 # ffffffffc0202d70 <commands+0xb68>
ffffffffc02018d2:	00001617          	auipc	a2,0x1
ffffffffc02018d6:	14660613          	addi	a2,a2,326 # ffffffffc0202a18 <commands+0x810>
ffffffffc02018da:	06200593          	li	a1,98
ffffffffc02018de:	00001517          	auipc	a0,0x1
ffffffffc02018e2:	15250513          	addi	a0,a0,338 # ffffffffc0202a30 <commands+0x828>
default_alloc_pages(size_t n) {
ffffffffc02018e6:	e406                	sd	ra,8(sp)
    assert(n > 0);
ffffffffc02018e8:	881fe0ef          	jal	ra,ffffffffc0200168 <__panic>

ffffffffc02018ec <default_init_memmap>:
default_init_memmap(struct Page *base, size_t n) {
ffffffffc02018ec:	1141                	addi	sp,sp,-16
ffffffffc02018ee:	e406                	sd	ra,8(sp)
    assert(n > 0);
ffffffffc02018f0:	c9e1                	beqz	a1,ffffffffc02019c0 <default_init_memmap+0xd4>
    for (; p != base + n; p ++) {
ffffffffc02018f2:	00259693          	slli	a3,a1,0x2
ffffffffc02018f6:	96ae                	add	a3,a3,a1
ffffffffc02018f8:	068e                	slli	a3,a3,0x3
ffffffffc02018fa:	96aa                	add	a3,a3,a0
ffffffffc02018fc:	87aa                	mv	a5,a0
ffffffffc02018fe:	00d50f63          	beq	a0,a3,ffffffffc020191c <default_init_memmap+0x30>
    return (((*(volatile unsigned long *)addr) >> nr) & 1);
ffffffffc0201902:	6798                	ld	a4,8(a5)
        assert(PageReserved(p));
ffffffffc0201904:	8b05                	andi	a4,a4,1
ffffffffc0201906:	cf49                	beqz	a4,ffffffffc02019a0 <default_init_memmap+0xb4>
        p->flags = p->property = 0;
ffffffffc0201908:	0007a823          	sw	zero,16(a5)
ffffffffc020190c:	0007b423          	sd	zero,8(a5)
ffffffffc0201910:	0007a023          	sw	zero,0(a5)
    for (; p != base + n; p ++) {
ffffffffc0201914:	02878793          	addi	a5,a5,40
ffffffffc0201918:	fed795e3          	bne	a5,a3,ffffffffc0201902 <default_init_memmap+0x16>
    base->property = n;
ffffffffc020191c:	2581                	sext.w	a1,a1
ffffffffc020191e:	c90c                	sw	a1,16(a0)
    __op_bit(or, __NOP, nr, ((volatile unsigned long *)addr));
ffffffffc0201920:	4789                	li	a5,2
ffffffffc0201922:	00850713          	addi	a4,a0,8
ffffffffc0201926:	40f7302f          	amoor.d	zero,a5,(a4)
    nr_free += n;
ffffffffc020192a:	00005697          	auipc	a3,0x5
ffffffffc020192e:	6fe68693          	addi	a3,a3,1790 # ffffffffc0207028 <free_area>
ffffffffc0201932:	4a98                	lw	a4,16(a3)
    return list->next == list;
ffffffffc0201934:	669c                	ld	a5,8(a3)
ffffffffc0201936:	01850613          	addi	a2,a0,24
ffffffffc020193a:	9db9                	addw	a1,a1,a4
ffffffffc020193c:	ca8c                	sw	a1,16(a3)
    if (list_empty(&free_list)) {
ffffffffc020193e:	04d78a63          	beq	a5,a3,ffffffffc0201992 <default_init_memmap+0xa6>
            struct Page* page = le2page(le, page_link);
ffffffffc0201942:	fe878713          	addi	a4,a5,-24
ffffffffc0201946:	0006b803          	ld	a6,0(a3)
    if (list_empty(&free_list)) {
ffffffffc020194a:	4581                	li	a1,0
            if (base < page) {
ffffffffc020194c:	00e56a63          	bltu	a0,a4,ffffffffc0201960 <default_init_memmap+0x74>
    return listelm->next;
ffffffffc0201950:	6798                	ld	a4,8(a5)
            } else if (list_next(le) == &free_list) {
ffffffffc0201952:	02d70263          	beq	a4,a3,ffffffffc0201976 <default_init_memmap+0x8a>
    for (; p != base + n; p ++) {
ffffffffc0201956:	87ba                	mv	a5,a4
            struct Page* page = le2page(le, page_link);
ffffffffc0201958:	fe878713          	addi	a4,a5,-24
            if (base < page) {
ffffffffc020195c:	fee57ae3          	bgeu	a0,a4,ffffffffc0201950 <default_init_memmap+0x64>
ffffffffc0201960:	c199                	beqz	a1,ffffffffc0201966 <default_init_memmap+0x7a>
ffffffffc0201962:	0106b023          	sd	a6,0(a3)
    __list_add(elm, listelm->prev, listelm);
ffffffffc0201966:	6398                	ld	a4,0(a5)
}
ffffffffc0201968:	60a2                	ld	ra,8(sp)
    prev->next = next->prev = elm;
ffffffffc020196a:	e390                	sd	a2,0(a5)
ffffffffc020196c:	e710                	sd	a2,8(a4)
    elm->next = next;
ffffffffc020196e:	f11c                	sd	a5,32(a0)
    elm->prev = prev;
ffffffffc0201970:	ed18                	sd	a4,24(a0)
ffffffffc0201972:	0141                	addi	sp,sp,16
ffffffffc0201974:	8082                	ret
    prev->next = next->prev = elm;
ffffffffc0201976:	e790                	sd	a2,8(a5)
    elm->next = next;
ffffffffc0201978:	f114                	sd	a3,32(a0)
    return listelm->next;
ffffffffc020197a:	6798                	ld	a4,8(a5)
    elm->prev = prev;
ffffffffc020197c:	ed1c                	sd	a5,24(a0)
        while ((le = list_next(le)) != &free_list) {
ffffffffc020197e:	00d70663          	beq	a4,a3,ffffffffc020198a <default_init_memmap+0x9e>
    prev->next = next->prev = elm;
ffffffffc0201982:	8832                	mv	a6,a2
ffffffffc0201984:	4585                	li	a1,1
    for (; p != base + n; p ++) {
ffffffffc0201986:	87ba                	mv	a5,a4
ffffffffc0201988:	bfc1                	j	ffffffffc0201958 <default_init_memmap+0x6c>
}
ffffffffc020198a:	60a2                	ld	ra,8(sp)
ffffffffc020198c:	e290                	sd	a2,0(a3)
ffffffffc020198e:	0141                	addi	sp,sp,16
ffffffffc0201990:	8082                	ret
ffffffffc0201992:	60a2                	ld	ra,8(sp)
ffffffffc0201994:	e390                	sd	a2,0(a5)
ffffffffc0201996:	e790                	sd	a2,8(a5)
    elm->next = next;
ffffffffc0201998:	f11c                	sd	a5,32(a0)
    elm->prev = prev;
ffffffffc020199a:	ed1c                	sd	a5,24(a0)
ffffffffc020199c:	0141                	addi	sp,sp,16
ffffffffc020199e:	8082                	ret
        assert(PageReserved(p));
ffffffffc02019a0:	00001697          	auipc	a3,0x1
ffffffffc02019a4:	40068693          	addi	a3,a3,1024 # ffffffffc0202da0 <commands+0xb98>
ffffffffc02019a8:	00001617          	auipc	a2,0x1
ffffffffc02019ac:	07060613          	addi	a2,a2,112 # ffffffffc0202a18 <commands+0x810>
ffffffffc02019b0:	04900593          	li	a1,73
ffffffffc02019b4:	00001517          	auipc	a0,0x1
ffffffffc02019b8:	07c50513          	addi	a0,a0,124 # ffffffffc0202a30 <commands+0x828>
ffffffffc02019bc:	facfe0ef          	jal	ra,ffffffffc0200168 <__panic>
    assert(n > 0);
ffffffffc02019c0:	00001697          	auipc	a3,0x1
ffffffffc02019c4:	3b068693          	addi	a3,a3,944 # ffffffffc0202d70 <commands+0xb68>
ffffffffc02019c8:	00001617          	auipc	a2,0x1
ffffffffc02019cc:	05060613          	addi	a2,a2,80 # ffffffffc0202a18 <commands+0x810>
ffffffffc02019d0:	04600593          	li	a1,70
ffffffffc02019d4:	00001517          	auipc	a0,0x1
ffffffffc02019d8:	05c50513          	addi	a0,a0,92 # ffffffffc0202a30 <commands+0x828>
ffffffffc02019dc:	f8cfe0ef          	jal	ra,ffffffffc0200168 <__panic>

ffffffffc02019e0 <strlen>:
 * The strlen() function returns the length of string @s.
 * */
size_t
strlen(const char *s) {
    size_t cnt = 0;
    while (*s ++ != '\0') {
ffffffffc02019e0:	00054783          	lbu	a5,0(a0)
strlen(const char *s) {
ffffffffc02019e4:	872a                	mv	a4,a0
    size_t cnt = 0;
ffffffffc02019e6:	4501                	li	a0,0
    while (*s ++ != '\0') {
ffffffffc02019e8:	cb81                	beqz	a5,ffffffffc02019f8 <strlen+0x18>
        cnt ++;
ffffffffc02019ea:	0505                	addi	a0,a0,1
    while (*s ++ != '\0') {
ffffffffc02019ec:	00a707b3          	add	a5,a4,a0
ffffffffc02019f0:	0007c783          	lbu	a5,0(a5)
ffffffffc02019f4:	fbfd                	bnez	a5,ffffffffc02019ea <strlen+0xa>
ffffffffc02019f6:	8082                	ret
    }
    return cnt;
}
ffffffffc02019f8:	8082                	ret

ffffffffc02019fa <strnlen>:
 * The return value is strlen(s), if that is less than @len, or
 * @len if there is no '\0' character among the first @len characters
 * pointed by @s.
 * */
size_t
strnlen(const char *s, size_t len) {
ffffffffc02019fa:	872a                	mv	a4,a0
    size_t cnt = 0;
ffffffffc02019fc:	4501                	li	a0,0
    while (cnt < len && *s ++ != '\0') {
ffffffffc02019fe:	e589                	bnez	a1,ffffffffc0201a08 <strnlen+0xe>
ffffffffc0201a00:	a811                	j	ffffffffc0201a14 <strnlen+0x1a>
        cnt ++;
ffffffffc0201a02:	0505                	addi	a0,a0,1
    while (cnt < len && *s ++ != '\0') {
ffffffffc0201a04:	00a58763          	beq	a1,a0,ffffffffc0201a12 <strnlen+0x18>
ffffffffc0201a08:	00a707b3          	add	a5,a4,a0
ffffffffc0201a0c:	0007c783          	lbu	a5,0(a5)
ffffffffc0201a10:	fbed                	bnez	a5,ffffffffc0201a02 <strnlen+0x8>
    }
    return cnt;
}
ffffffffc0201a12:	8082                	ret
ffffffffc0201a14:	8082                	ret

ffffffffc0201a16 <strcmp>:
int
strcmp(const char *s1, const char *s2) {
#ifdef __HAVE_ARCH_STRCMP
    return __strcmp(s1, s2);
#else
    while (*s1 != '\0' && *s1 == *s2) {
ffffffffc0201a16:	00054783          	lbu	a5,0(a0)
ffffffffc0201a1a:	0005c703          	lbu	a4,0(a1)
ffffffffc0201a1e:	cb89                	beqz	a5,ffffffffc0201a30 <strcmp+0x1a>
        s1 ++, s2 ++;
ffffffffc0201a20:	0505                	addi	a0,a0,1
ffffffffc0201a22:	0585                	addi	a1,a1,1
    while (*s1 != '\0' && *s1 == *s2) {
ffffffffc0201a24:	fee789e3          	beq	a5,a4,ffffffffc0201a16 <strcmp>
ffffffffc0201a28:	0007851b          	sext.w	a0,a5
    }
    return (int)((unsigned char)*s1 - (unsigned char)*s2);
#endif /* __HAVE_ARCH_STRCMP */
}
ffffffffc0201a2c:	9d19                	subw	a0,a0,a4
ffffffffc0201a2e:	8082                	ret
ffffffffc0201a30:	4501                	li	a0,0
ffffffffc0201a32:	bfed                	j	ffffffffc0201a2c <strcmp+0x16>

ffffffffc0201a34 <strncmp>:
 * the characters differ, until a terminating null-character is reached, or
 * until @n characters match in both strings, whichever happens first.
 * */
int
strncmp(const char *s1, const char *s2, size_t n) {
    while (n > 0 && *s1 != '\0' && *s1 == *s2) {
ffffffffc0201a34:	c20d                	beqz	a2,ffffffffc0201a56 <strncmp+0x22>
ffffffffc0201a36:	962e                	add	a2,a2,a1
ffffffffc0201a38:	a031                	j	ffffffffc0201a44 <strncmp+0x10>
        n --, s1 ++, s2 ++;
ffffffffc0201a3a:	0505                	addi	a0,a0,1
    while (n > 0 && *s1 != '\0' && *s1 == *s2) {
ffffffffc0201a3c:	00e79a63          	bne	a5,a4,ffffffffc0201a50 <strncmp+0x1c>
ffffffffc0201a40:	00b60b63          	beq	a2,a1,ffffffffc0201a56 <strncmp+0x22>
ffffffffc0201a44:	00054783          	lbu	a5,0(a0)
        n --, s1 ++, s2 ++;
ffffffffc0201a48:	0585                	addi	a1,a1,1
ffffffffc0201a4a:	fff5c703          	lbu	a4,-1(a1)
    while (n > 0 && *s1 != '\0' && *s1 == *s2) {
ffffffffc0201a4e:	f7f5                	bnez	a5,ffffffffc0201a3a <strncmp+0x6>
    }
    return (n == 0) ? 0 : (int)((unsigned char)*s1 - (unsigned char)*s2);
ffffffffc0201a50:	40e7853b          	subw	a0,a5,a4
}
ffffffffc0201a54:	8082                	ret
    return (n == 0) ? 0 : (int)((unsigned char)*s1 - (unsigned char)*s2);
ffffffffc0201a56:	4501                	li	a0,0
ffffffffc0201a58:	8082                	ret

ffffffffc0201a5a <strchr>:
 * The strchr() function returns a pointer to the first occurrence of
 * character in @s. If the value is not found, the function returns 'NULL'.
 * */
char *
strchr(const char *s, char c) {
    while (*s != '\0') {
ffffffffc0201a5a:	00054783          	lbu	a5,0(a0)
ffffffffc0201a5e:	c799                	beqz	a5,ffffffffc0201a6c <strchr+0x12>
        if (*s == c) {
ffffffffc0201a60:	00f58763          	beq	a1,a5,ffffffffc0201a6e <strchr+0x14>
    while (*s != '\0') {
ffffffffc0201a64:	00154783          	lbu	a5,1(a0)
            return (char *)s;
        }
        s ++;
ffffffffc0201a68:	0505                	addi	a0,a0,1
    while (*s != '\0') {
ffffffffc0201a6a:	fbfd                	bnez	a5,ffffffffc0201a60 <strchr+0x6>
    }
    return NULL;
ffffffffc0201a6c:	4501                	li	a0,0
}
ffffffffc0201a6e:	8082                	ret

ffffffffc0201a70 <memset>:
memset(void *s, char c, size_t n) {
#ifdef __HAVE_ARCH_MEMSET
    return __memset(s, c, n);
#else
    char *p = s;
    while (n -- > 0) {
ffffffffc0201a70:	ca01                	beqz	a2,ffffffffc0201a80 <memset+0x10>
ffffffffc0201a72:	962a                	add	a2,a2,a0
    char *p = s;
ffffffffc0201a74:	87aa                	mv	a5,a0
        *p ++ = c;
ffffffffc0201a76:	0785                	addi	a5,a5,1
ffffffffc0201a78:	feb78fa3          	sb	a1,-1(a5)
    while (n -- > 0) {
ffffffffc0201a7c:	fec79de3          	bne	a5,a2,ffffffffc0201a76 <memset+0x6>
    }
    return s;
#endif /* __HAVE_ARCH_MEMSET */
}
ffffffffc0201a80:	8082                	ret

ffffffffc0201a82 <printnum>:
 * */
static void
printnum(void (*putch)(int, void*), void *putdat,
        unsigned long long num, unsigned base, int width, int padc) {
    unsigned long long result = num;
    unsigned mod = do_div(result, base);
ffffffffc0201a82:	02069813          	slli	a6,a3,0x20
        unsigned long long num, unsigned base, int width, int padc) {
ffffffffc0201a86:	7179                	addi	sp,sp,-48
    unsigned mod = do_div(result, base);
ffffffffc0201a88:	02085813          	srli	a6,a6,0x20
        unsigned long long num, unsigned base, int width, int padc) {
ffffffffc0201a8c:	e052                	sd	s4,0(sp)
    unsigned mod = do_div(result, base);
ffffffffc0201a8e:	03067a33          	remu	s4,a2,a6
        unsigned long long num, unsigned base, int width, int padc) {
ffffffffc0201a92:	f022                	sd	s0,32(sp)
ffffffffc0201a94:	ec26                	sd	s1,24(sp)
ffffffffc0201a96:	e84a                	sd	s2,16(sp)
ffffffffc0201a98:	f406                	sd	ra,40(sp)
ffffffffc0201a9a:	e44e                	sd	s3,8(sp)
ffffffffc0201a9c:	84aa                	mv	s1,a0
ffffffffc0201a9e:	892e                	mv	s2,a1
ffffffffc0201aa0:	fff7041b          	addiw	s0,a4,-1
    unsigned mod = do_div(result, base);
ffffffffc0201aa4:	2a01                	sext.w	s4,s4

    // first recursively print all preceding (more significant) digits
    if (num >= base) {
ffffffffc0201aa6:	03067e63          	bgeu	a2,a6,ffffffffc0201ae2 <printnum+0x60>
ffffffffc0201aaa:	89be                	mv	s3,a5
        printnum(putch, putdat, result, base, width - 1, padc);
    } else {
        // print any needed pad characters before first digit
        while (-- width > 0)
ffffffffc0201aac:	00805763          	blez	s0,ffffffffc0201aba <printnum+0x38>
ffffffffc0201ab0:	347d                	addiw	s0,s0,-1
            putch(padc, putdat);
ffffffffc0201ab2:	85ca                	mv	a1,s2
ffffffffc0201ab4:	854e                	mv	a0,s3
ffffffffc0201ab6:	9482                	jalr	s1
        while (-- width > 0)
ffffffffc0201ab8:	fc65                	bnez	s0,ffffffffc0201ab0 <printnum+0x2e>
    }
    // then print this (the least significant) digit
    putch("0123456789abcdef"[mod], putdat);
ffffffffc0201aba:	1a02                	slli	s4,s4,0x20
ffffffffc0201abc:	020a5a13          	srli	s4,s4,0x20
ffffffffc0201ac0:	00001797          	auipc	a5,0x1
ffffffffc0201ac4:	34078793          	addi	a5,a5,832 # ffffffffc0202e00 <default_pmm_manager+0x38>
}
ffffffffc0201ac8:	7402                	ld	s0,32(sp)
    putch("0123456789abcdef"[mod], putdat);
ffffffffc0201aca:	9a3e                	add	s4,s4,a5
ffffffffc0201acc:	000a4503          	lbu	a0,0(s4)
}
ffffffffc0201ad0:	70a2                	ld	ra,40(sp)
ffffffffc0201ad2:	69a2                	ld	s3,8(sp)
ffffffffc0201ad4:	6a02                	ld	s4,0(sp)
    putch("0123456789abcdef"[mod], putdat);
ffffffffc0201ad6:	85ca                	mv	a1,s2
ffffffffc0201ad8:	8326                	mv	t1,s1
}
ffffffffc0201ada:	6942                	ld	s2,16(sp)
ffffffffc0201adc:	64e2                	ld	s1,24(sp)
ffffffffc0201ade:	6145                	addi	sp,sp,48
    putch("0123456789abcdef"[mod], putdat);
ffffffffc0201ae0:	8302                	jr	t1
        printnum(putch, putdat, result, base, width - 1, padc);
ffffffffc0201ae2:	03065633          	divu	a2,a2,a6
ffffffffc0201ae6:	8722                	mv	a4,s0
ffffffffc0201ae8:	f9bff0ef          	jal	ra,ffffffffc0201a82 <printnum>
ffffffffc0201aec:	b7f9                	j	ffffffffc0201aba <printnum+0x38>

ffffffffc0201aee <vprintfmt>:
 *
 * Call this function if you are already dealing with a va_list.
 * Or you probably want printfmt() instead.
 * */
void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap) {
ffffffffc0201aee:	7119                	addi	sp,sp,-128
ffffffffc0201af0:	f4a6                	sd	s1,104(sp)
ffffffffc0201af2:	f0ca                	sd	s2,96(sp)
ffffffffc0201af4:	ecce                	sd	s3,88(sp)
ffffffffc0201af6:	e8d2                	sd	s4,80(sp)
ffffffffc0201af8:	e4d6                	sd	s5,72(sp)
ffffffffc0201afa:	e0da                	sd	s6,64(sp)
ffffffffc0201afc:	fc5e                	sd	s7,56(sp)
ffffffffc0201afe:	f06a                	sd	s10,32(sp)
ffffffffc0201b00:	fc86                	sd	ra,120(sp)
ffffffffc0201b02:	f8a2                	sd	s0,112(sp)
ffffffffc0201b04:	f862                	sd	s8,48(sp)
ffffffffc0201b06:	f466                	sd	s9,40(sp)
ffffffffc0201b08:	ec6e                	sd	s11,24(sp)
ffffffffc0201b0a:	892a                	mv	s2,a0
ffffffffc0201b0c:	84ae                	mv	s1,a1
ffffffffc0201b0e:	8d32                	mv	s10,a2
ffffffffc0201b10:	8a36                	mv	s4,a3
    register int ch, err;
    unsigned long long num;
    int base, width, precision, lflag, altflag;

    while (1) {
        while ((ch = *(unsigned char *)fmt ++) != '%') {
ffffffffc0201b12:	02500993          	li	s3,37
            putch(ch, putdat);
        }

        // Process a %-escape sequence
        char padc = ' ';
        width = precision = -1;
ffffffffc0201b16:	5b7d                	li	s6,-1
ffffffffc0201b18:	00001a97          	auipc	s5,0x1
ffffffffc0201b1c:	31ca8a93          	addi	s5,s5,796 # ffffffffc0202e34 <default_pmm_manager+0x6c>
        case 'e':
            err = va_arg(ap, int);
            if (err < 0) {
                err = -err;
            }
            if (err > MAXERROR || (p = error_string[err]) == NULL) {
ffffffffc0201b20:	00001b97          	auipc	s7,0x1
ffffffffc0201b24:	4f0b8b93          	addi	s7,s7,1264 # ffffffffc0203010 <error_string>
        while ((ch = *(unsigned char *)fmt ++) != '%') {
ffffffffc0201b28:	000d4503          	lbu	a0,0(s10) # ff0000 <kern_entry-0xffffffffbf210000>
ffffffffc0201b2c:	001d0413          	addi	s0,s10,1
ffffffffc0201b30:	01350a63          	beq	a0,s3,ffffffffc0201b44 <vprintfmt+0x56>
            if (ch == '\0') {
ffffffffc0201b34:	c121                	beqz	a0,ffffffffc0201b74 <vprintfmt+0x86>
            putch(ch, putdat);
ffffffffc0201b36:	85a6                	mv	a1,s1
        while ((ch = *(unsigned char *)fmt ++) != '%') {
ffffffffc0201b38:	0405                	addi	s0,s0,1
            putch(ch, putdat);
ffffffffc0201b3a:	9902                	jalr	s2
        while ((ch = *(unsigned char *)fmt ++) != '%') {
ffffffffc0201b3c:	fff44503          	lbu	a0,-1(s0)
ffffffffc0201b40:	ff351ae3          	bne	a0,s3,ffffffffc0201b34 <vprintfmt+0x46>
ffffffffc0201b44:	00044603          	lbu	a2,0(s0)
        char padc = ' ';
ffffffffc0201b48:	02000793          	li	a5,32
        lflag = altflag = 0;
ffffffffc0201b4c:	4c81                	li	s9,0
ffffffffc0201b4e:	4881                	li	a7,0
        width = precision = -1;
ffffffffc0201b50:	5c7d                	li	s8,-1
ffffffffc0201b52:	5dfd                	li	s11,-1
ffffffffc0201b54:	05500513          	li	a0,85
                if (ch < '0' || ch > '9') {
ffffffffc0201b58:	4825                	li	a6,9
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0201b5a:	fdd6059b          	addiw	a1,a2,-35
ffffffffc0201b5e:	0ff5f593          	andi	a1,a1,255
ffffffffc0201b62:	00140d13          	addi	s10,s0,1
ffffffffc0201b66:	04b56263          	bltu	a0,a1,ffffffffc0201baa <vprintfmt+0xbc>
ffffffffc0201b6a:	058a                	slli	a1,a1,0x2
ffffffffc0201b6c:	95d6                	add	a1,a1,s5
ffffffffc0201b6e:	4194                	lw	a3,0(a1)
ffffffffc0201b70:	96d6                	add	a3,a3,s5
ffffffffc0201b72:	8682                	jr	a3
            for (fmt --; fmt[-1] != '%'; fmt --)
                /* do nothing */;
            break;
        }
    }
}
ffffffffc0201b74:	70e6                	ld	ra,120(sp)
ffffffffc0201b76:	7446                	ld	s0,112(sp)
ffffffffc0201b78:	74a6                	ld	s1,104(sp)
ffffffffc0201b7a:	7906                	ld	s2,96(sp)
ffffffffc0201b7c:	69e6                	ld	s3,88(sp)
ffffffffc0201b7e:	6a46                	ld	s4,80(sp)
ffffffffc0201b80:	6aa6                	ld	s5,72(sp)
ffffffffc0201b82:	6b06                	ld	s6,64(sp)
ffffffffc0201b84:	7be2                	ld	s7,56(sp)
ffffffffc0201b86:	7c42                	ld	s8,48(sp)
ffffffffc0201b88:	7ca2                	ld	s9,40(sp)
ffffffffc0201b8a:	7d02                	ld	s10,32(sp)
ffffffffc0201b8c:	6de2                	ld	s11,24(sp)
ffffffffc0201b8e:	6109                	addi	sp,sp,128
ffffffffc0201b90:	8082                	ret
            padc = '0';
ffffffffc0201b92:	87b2                	mv	a5,a2
            goto reswitch;
ffffffffc0201b94:	00144603          	lbu	a2,1(s0)
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0201b98:	846a                	mv	s0,s10
ffffffffc0201b9a:	00140d13          	addi	s10,s0,1
ffffffffc0201b9e:	fdd6059b          	addiw	a1,a2,-35
ffffffffc0201ba2:	0ff5f593          	andi	a1,a1,255
ffffffffc0201ba6:	fcb572e3          	bgeu	a0,a1,ffffffffc0201b6a <vprintfmt+0x7c>
            putch('%', putdat);
ffffffffc0201baa:	85a6                	mv	a1,s1
ffffffffc0201bac:	02500513          	li	a0,37
ffffffffc0201bb0:	9902                	jalr	s2
            for (fmt --; fmt[-1] != '%'; fmt --)
ffffffffc0201bb2:	fff44783          	lbu	a5,-1(s0)
ffffffffc0201bb6:	8d22                	mv	s10,s0
ffffffffc0201bb8:	f73788e3          	beq	a5,s3,ffffffffc0201b28 <vprintfmt+0x3a>
ffffffffc0201bbc:	ffed4783          	lbu	a5,-2(s10)
ffffffffc0201bc0:	1d7d                	addi	s10,s10,-1
ffffffffc0201bc2:	ff379de3          	bne	a5,s3,ffffffffc0201bbc <vprintfmt+0xce>
ffffffffc0201bc6:	b78d                	j	ffffffffc0201b28 <vprintfmt+0x3a>
                precision = precision * 10 + ch - '0';
ffffffffc0201bc8:	fd060c1b          	addiw	s8,a2,-48
                ch = *fmt;
ffffffffc0201bcc:	00144603          	lbu	a2,1(s0)
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0201bd0:	846a                	mv	s0,s10
                if (ch < '0' || ch > '9') {
ffffffffc0201bd2:	fd06069b          	addiw	a3,a2,-48
                ch = *fmt;
ffffffffc0201bd6:	0006059b          	sext.w	a1,a2
                if (ch < '0' || ch > '9') {
ffffffffc0201bda:	02d86463          	bltu	a6,a3,ffffffffc0201c02 <vprintfmt+0x114>
                ch = *fmt;
ffffffffc0201bde:	00144603          	lbu	a2,1(s0)
                precision = precision * 10 + ch - '0';
ffffffffc0201be2:	002c169b          	slliw	a3,s8,0x2
ffffffffc0201be6:	0186873b          	addw	a4,a3,s8
ffffffffc0201bea:	0017171b          	slliw	a4,a4,0x1
ffffffffc0201bee:	9f2d                	addw	a4,a4,a1
                if (ch < '0' || ch > '9') {
ffffffffc0201bf0:	fd06069b          	addiw	a3,a2,-48
            for (precision = 0; ; ++ fmt) {
ffffffffc0201bf4:	0405                	addi	s0,s0,1
                precision = precision * 10 + ch - '0';
ffffffffc0201bf6:	fd070c1b          	addiw	s8,a4,-48
                ch = *fmt;
ffffffffc0201bfa:	0006059b          	sext.w	a1,a2
                if (ch < '0' || ch > '9') {
ffffffffc0201bfe:	fed870e3          	bgeu	a6,a3,ffffffffc0201bde <vprintfmt+0xf0>
            if (width < 0)
ffffffffc0201c02:	f40ddce3          	bgez	s11,ffffffffc0201b5a <vprintfmt+0x6c>
                width = precision, precision = -1;
ffffffffc0201c06:	8de2                	mv	s11,s8
ffffffffc0201c08:	5c7d                	li	s8,-1
ffffffffc0201c0a:	bf81                	j	ffffffffc0201b5a <vprintfmt+0x6c>
            if (width < 0)
ffffffffc0201c0c:	fffdc693          	not	a3,s11
ffffffffc0201c10:	96fd                	srai	a3,a3,0x3f
ffffffffc0201c12:	00ddfdb3          	and	s11,s11,a3
ffffffffc0201c16:	00144603          	lbu	a2,1(s0)
ffffffffc0201c1a:	2d81                	sext.w	s11,s11
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0201c1c:	846a                	mv	s0,s10
            goto reswitch;
ffffffffc0201c1e:	bf35                	j	ffffffffc0201b5a <vprintfmt+0x6c>
            precision = va_arg(ap, int);
ffffffffc0201c20:	000a2c03          	lw	s8,0(s4)
            goto process_precision;
ffffffffc0201c24:	00144603          	lbu	a2,1(s0)
            precision = va_arg(ap, int);
ffffffffc0201c28:	0a21                	addi	s4,s4,8
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0201c2a:	846a                	mv	s0,s10
            goto process_precision;
ffffffffc0201c2c:	bfd9                	j	ffffffffc0201c02 <vprintfmt+0x114>
    if (lflag >= 2) {
ffffffffc0201c2e:	4705                	li	a4,1
ffffffffc0201c30:	008a0593          	addi	a1,s4,8
ffffffffc0201c34:	01174463          	blt	a4,a7,ffffffffc0201c3c <vprintfmt+0x14e>
    else if (lflag) {
ffffffffc0201c38:	1a088e63          	beqz	a7,ffffffffc0201df4 <vprintfmt+0x306>
        return va_arg(*ap, unsigned long);
ffffffffc0201c3c:	000a3603          	ld	a2,0(s4)
ffffffffc0201c40:	46c1                	li	a3,16
ffffffffc0201c42:	8a2e                	mv	s4,a1
            printnum(putch, putdat, num, base, width, padc);
ffffffffc0201c44:	2781                	sext.w	a5,a5
ffffffffc0201c46:	876e                	mv	a4,s11
ffffffffc0201c48:	85a6                	mv	a1,s1
ffffffffc0201c4a:	854a                	mv	a0,s2
ffffffffc0201c4c:	e37ff0ef          	jal	ra,ffffffffc0201a82 <printnum>
            break;
ffffffffc0201c50:	bde1                	j	ffffffffc0201b28 <vprintfmt+0x3a>
            putch(va_arg(ap, int), putdat);
ffffffffc0201c52:	000a2503          	lw	a0,0(s4)
ffffffffc0201c56:	85a6                	mv	a1,s1
ffffffffc0201c58:	0a21                	addi	s4,s4,8
ffffffffc0201c5a:	9902                	jalr	s2
            break;
ffffffffc0201c5c:	b5f1                	j	ffffffffc0201b28 <vprintfmt+0x3a>
    if (lflag >= 2) {
ffffffffc0201c5e:	4705                	li	a4,1
ffffffffc0201c60:	008a0593          	addi	a1,s4,8
ffffffffc0201c64:	01174463          	blt	a4,a7,ffffffffc0201c6c <vprintfmt+0x17e>
    else if (lflag) {
ffffffffc0201c68:	18088163          	beqz	a7,ffffffffc0201dea <vprintfmt+0x2fc>
        return va_arg(*ap, unsigned long);
ffffffffc0201c6c:	000a3603          	ld	a2,0(s4)
ffffffffc0201c70:	46a9                	li	a3,10
ffffffffc0201c72:	8a2e                	mv	s4,a1
ffffffffc0201c74:	bfc1                	j	ffffffffc0201c44 <vprintfmt+0x156>
            goto reswitch;
ffffffffc0201c76:	00144603          	lbu	a2,1(s0)
            altflag = 1;
ffffffffc0201c7a:	4c85                	li	s9,1
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0201c7c:	846a                	mv	s0,s10
            goto reswitch;
ffffffffc0201c7e:	bdf1                	j	ffffffffc0201b5a <vprintfmt+0x6c>
            putch(ch, putdat);
ffffffffc0201c80:	85a6                	mv	a1,s1
ffffffffc0201c82:	02500513          	li	a0,37
ffffffffc0201c86:	9902                	jalr	s2
            break;
ffffffffc0201c88:	b545                	j	ffffffffc0201b28 <vprintfmt+0x3a>
            lflag ++;
ffffffffc0201c8a:	00144603          	lbu	a2,1(s0)
ffffffffc0201c8e:	2885                	addiw	a7,a7,1
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0201c90:	846a                	mv	s0,s10
            goto reswitch;
ffffffffc0201c92:	b5e1                	j	ffffffffc0201b5a <vprintfmt+0x6c>
    if (lflag >= 2) {
ffffffffc0201c94:	4705                	li	a4,1
ffffffffc0201c96:	008a0593          	addi	a1,s4,8
ffffffffc0201c9a:	01174463          	blt	a4,a7,ffffffffc0201ca2 <vprintfmt+0x1b4>
    else if (lflag) {
ffffffffc0201c9e:	14088163          	beqz	a7,ffffffffc0201de0 <vprintfmt+0x2f2>
        return va_arg(*ap, unsigned long);
ffffffffc0201ca2:	000a3603          	ld	a2,0(s4)
ffffffffc0201ca6:	46a1                	li	a3,8
ffffffffc0201ca8:	8a2e                	mv	s4,a1
ffffffffc0201caa:	bf69                	j	ffffffffc0201c44 <vprintfmt+0x156>
            putch('0', putdat);
ffffffffc0201cac:	03000513          	li	a0,48
ffffffffc0201cb0:	85a6                	mv	a1,s1
ffffffffc0201cb2:	e03e                	sd	a5,0(sp)
ffffffffc0201cb4:	9902                	jalr	s2
            putch('x', putdat);
ffffffffc0201cb6:	85a6                	mv	a1,s1
ffffffffc0201cb8:	07800513          	li	a0,120
ffffffffc0201cbc:	9902                	jalr	s2
            num = (unsigned long long)(uintptr_t)va_arg(ap, void *);
ffffffffc0201cbe:	0a21                	addi	s4,s4,8
            goto number;
ffffffffc0201cc0:	6782                	ld	a5,0(sp)
ffffffffc0201cc2:	46c1                	li	a3,16
            num = (unsigned long long)(uintptr_t)va_arg(ap, void *);
ffffffffc0201cc4:	ff8a3603          	ld	a2,-8(s4)
            goto number;
ffffffffc0201cc8:	bfb5                	j	ffffffffc0201c44 <vprintfmt+0x156>
            if ((p = va_arg(ap, char *)) == NULL) {
ffffffffc0201cca:	000a3403          	ld	s0,0(s4)
ffffffffc0201cce:	008a0713          	addi	a4,s4,8
ffffffffc0201cd2:	e03a                	sd	a4,0(sp)
ffffffffc0201cd4:	14040263          	beqz	s0,ffffffffc0201e18 <vprintfmt+0x32a>
            if (width > 0 && padc != '-') {
ffffffffc0201cd8:	0fb05763          	blez	s11,ffffffffc0201dc6 <vprintfmt+0x2d8>
ffffffffc0201cdc:	02d00693          	li	a3,45
ffffffffc0201ce0:	0cd79163          	bne	a5,a3,ffffffffc0201da2 <vprintfmt+0x2b4>
            for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
ffffffffc0201ce4:	00044783          	lbu	a5,0(s0)
ffffffffc0201ce8:	0007851b          	sext.w	a0,a5
ffffffffc0201cec:	cf85                	beqz	a5,ffffffffc0201d24 <vprintfmt+0x236>
ffffffffc0201cee:	00140a13          	addi	s4,s0,1
                if (altflag && (ch < ' ' || ch > '~')) {
ffffffffc0201cf2:	05e00413          	li	s0,94
            for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
ffffffffc0201cf6:	000c4563          	bltz	s8,ffffffffc0201d00 <vprintfmt+0x212>
ffffffffc0201cfa:	3c7d                	addiw	s8,s8,-1
ffffffffc0201cfc:	036c0263          	beq	s8,s6,ffffffffc0201d20 <vprintfmt+0x232>
                    putch('?', putdat);
ffffffffc0201d00:	85a6                	mv	a1,s1
                if (altflag && (ch < ' ' || ch > '~')) {
ffffffffc0201d02:	0e0c8e63          	beqz	s9,ffffffffc0201dfe <vprintfmt+0x310>
ffffffffc0201d06:	3781                	addiw	a5,a5,-32
ffffffffc0201d08:	0ef47b63          	bgeu	s0,a5,ffffffffc0201dfe <vprintfmt+0x310>
                    putch('?', putdat);
ffffffffc0201d0c:	03f00513          	li	a0,63
ffffffffc0201d10:	9902                	jalr	s2
            for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
ffffffffc0201d12:	000a4783          	lbu	a5,0(s4)
ffffffffc0201d16:	3dfd                	addiw	s11,s11,-1
ffffffffc0201d18:	0a05                	addi	s4,s4,1
ffffffffc0201d1a:	0007851b          	sext.w	a0,a5
ffffffffc0201d1e:	ffe1                	bnez	a5,ffffffffc0201cf6 <vprintfmt+0x208>
            for (; width > 0; width --) {
ffffffffc0201d20:	01b05963          	blez	s11,ffffffffc0201d32 <vprintfmt+0x244>
ffffffffc0201d24:	3dfd                	addiw	s11,s11,-1
                putch(' ', putdat);
ffffffffc0201d26:	85a6                	mv	a1,s1
ffffffffc0201d28:	02000513          	li	a0,32
ffffffffc0201d2c:	9902                	jalr	s2
            for (; width > 0; width --) {
ffffffffc0201d2e:	fe0d9be3          	bnez	s11,ffffffffc0201d24 <vprintfmt+0x236>
            if ((p = va_arg(ap, char *)) == NULL) {
ffffffffc0201d32:	6a02                	ld	s4,0(sp)
ffffffffc0201d34:	bbd5                	j	ffffffffc0201b28 <vprintfmt+0x3a>
    if (lflag >= 2) {
ffffffffc0201d36:	4705                	li	a4,1
ffffffffc0201d38:	008a0c93          	addi	s9,s4,8
ffffffffc0201d3c:	01174463          	blt	a4,a7,ffffffffc0201d44 <vprintfmt+0x256>
    else if (lflag) {
ffffffffc0201d40:	08088d63          	beqz	a7,ffffffffc0201dda <vprintfmt+0x2ec>
        return va_arg(*ap, long);
ffffffffc0201d44:	000a3403          	ld	s0,0(s4)
            if ((long long)num < 0) {
ffffffffc0201d48:	0a044d63          	bltz	s0,ffffffffc0201e02 <vprintfmt+0x314>
            num = getint(&ap, lflag);
ffffffffc0201d4c:	8622                	mv	a2,s0
ffffffffc0201d4e:	8a66                	mv	s4,s9
ffffffffc0201d50:	46a9                	li	a3,10
ffffffffc0201d52:	bdcd                	j	ffffffffc0201c44 <vprintfmt+0x156>
            err = va_arg(ap, int);
ffffffffc0201d54:	000a2783          	lw	a5,0(s4)
            if (err > MAXERROR || (p = error_string[err]) == NULL) {
ffffffffc0201d58:	4719                	li	a4,6
            err = va_arg(ap, int);
ffffffffc0201d5a:	0a21                	addi	s4,s4,8
            if (err < 0) {
ffffffffc0201d5c:	41f7d69b          	sraiw	a3,a5,0x1f
ffffffffc0201d60:	8fb5                	xor	a5,a5,a3
ffffffffc0201d62:	40d786bb          	subw	a3,a5,a3
            if (err > MAXERROR || (p = error_string[err]) == NULL) {
ffffffffc0201d66:	02d74163          	blt	a4,a3,ffffffffc0201d88 <vprintfmt+0x29a>
ffffffffc0201d6a:	00369793          	slli	a5,a3,0x3
ffffffffc0201d6e:	97de                	add	a5,a5,s7
ffffffffc0201d70:	639c                	ld	a5,0(a5)
ffffffffc0201d72:	cb99                	beqz	a5,ffffffffc0201d88 <vprintfmt+0x29a>
                printfmt(putch, putdat, "%s", p);
ffffffffc0201d74:	86be                	mv	a3,a5
ffffffffc0201d76:	00001617          	auipc	a2,0x1
ffffffffc0201d7a:	0ba60613          	addi	a2,a2,186 # ffffffffc0202e30 <default_pmm_manager+0x68>
ffffffffc0201d7e:	85a6                	mv	a1,s1
ffffffffc0201d80:	854a                	mv	a0,s2
ffffffffc0201d82:	0ce000ef          	jal	ra,ffffffffc0201e50 <printfmt>
ffffffffc0201d86:	b34d                	j	ffffffffc0201b28 <vprintfmt+0x3a>
                printfmt(putch, putdat, "error %d", err);
ffffffffc0201d88:	00001617          	auipc	a2,0x1
ffffffffc0201d8c:	09860613          	addi	a2,a2,152 # ffffffffc0202e20 <default_pmm_manager+0x58>
ffffffffc0201d90:	85a6                	mv	a1,s1
ffffffffc0201d92:	854a                	mv	a0,s2
ffffffffc0201d94:	0bc000ef          	jal	ra,ffffffffc0201e50 <printfmt>
ffffffffc0201d98:	bb41                	j	ffffffffc0201b28 <vprintfmt+0x3a>
                p = "(null)";
ffffffffc0201d9a:	00001417          	auipc	s0,0x1
ffffffffc0201d9e:	07e40413          	addi	s0,s0,126 # ffffffffc0202e18 <default_pmm_manager+0x50>
                for (width -= strnlen(p, precision); width > 0; width --) {
ffffffffc0201da2:	85e2                	mv	a1,s8
ffffffffc0201da4:	8522                	mv	a0,s0
ffffffffc0201da6:	e43e                	sd	a5,8(sp)
ffffffffc0201da8:	c53ff0ef          	jal	ra,ffffffffc02019fa <strnlen>
ffffffffc0201dac:	40ad8dbb          	subw	s11,s11,a0
ffffffffc0201db0:	01b05b63          	blez	s11,ffffffffc0201dc6 <vprintfmt+0x2d8>
ffffffffc0201db4:	67a2                	ld	a5,8(sp)
ffffffffc0201db6:	00078a1b          	sext.w	s4,a5
ffffffffc0201dba:	3dfd                	addiw	s11,s11,-1
                    putch(padc, putdat);
ffffffffc0201dbc:	85a6                	mv	a1,s1
ffffffffc0201dbe:	8552                	mv	a0,s4
ffffffffc0201dc0:	9902                	jalr	s2
                for (width -= strnlen(p, precision); width > 0; width --) {
ffffffffc0201dc2:	fe0d9ce3          	bnez	s11,ffffffffc0201dba <vprintfmt+0x2cc>
            for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
ffffffffc0201dc6:	00044783          	lbu	a5,0(s0)
ffffffffc0201dca:	00140a13          	addi	s4,s0,1
ffffffffc0201dce:	0007851b          	sext.w	a0,a5
ffffffffc0201dd2:	d3a5                	beqz	a5,ffffffffc0201d32 <vprintfmt+0x244>
                if (altflag && (ch < ' ' || ch > '~')) {
ffffffffc0201dd4:	05e00413          	li	s0,94
ffffffffc0201dd8:	bf39                	j	ffffffffc0201cf6 <vprintfmt+0x208>
        return va_arg(*ap, int);
ffffffffc0201dda:	000a2403          	lw	s0,0(s4)
ffffffffc0201dde:	b7ad                	j	ffffffffc0201d48 <vprintfmt+0x25a>
        return va_arg(*ap, unsigned int);
ffffffffc0201de0:	000a6603          	lwu	a2,0(s4)
ffffffffc0201de4:	46a1                	li	a3,8
ffffffffc0201de6:	8a2e                	mv	s4,a1
ffffffffc0201de8:	bdb1                	j	ffffffffc0201c44 <vprintfmt+0x156>
ffffffffc0201dea:	000a6603          	lwu	a2,0(s4)
ffffffffc0201dee:	46a9                	li	a3,10
ffffffffc0201df0:	8a2e                	mv	s4,a1
ffffffffc0201df2:	bd89                	j	ffffffffc0201c44 <vprintfmt+0x156>
ffffffffc0201df4:	000a6603          	lwu	a2,0(s4)
ffffffffc0201df8:	46c1                	li	a3,16
ffffffffc0201dfa:	8a2e                	mv	s4,a1
ffffffffc0201dfc:	b5a1                	j	ffffffffc0201c44 <vprintfmt+0x156>
                    putch(ch, putdat);
ffffffffc0201dfe:	9902                	jalr	s2
ffffffffc0201e00:	bf09                	j	ffffffffc0201d12 <vprintfmt+0x224>
                putch('-', putdat);
ffffffffc0201e02:	85a6                	mv	a1,s1
ffffffffc0201e04:	02d00513          	li	a0,45
ffffffffc0201e08:	e03e                	sd	a5,0(sp)
ffffffffc0201e0a:	9902                	jalr	s2
                num = -(long long)num;
ffffffffc0201e0c:	6782                	ld	a5,0(sp)
ffffffffc0201e0e:	8a66                	mv	s4,s9
ffffffffc0201e10:	40800633          	neg	a2,s0
ffffffffc0201e14:	46a9                	li	a3,10
ffffffffc0201e16:	b53d                	j	ffffffffc0201c44 <vprintfmt+0x156>
            if (width > 0 && padc != '-') {
ffffffffc0201e18:	03b05163          	blez	s11,ffffffffc0201e3a <vprintfmt+0x34c>
ffffffffc0201e1c:	02d00693          	li	a3,45
ffffffffc0201e20:	f6d79de3          	bne	a5,a3,ffffffffc0201d9a <vprintfmt+0x2ac>
                p = "(null)";
ffffffffc0201e24:	00001417          	auipc	s0,0x1
ffffffffc0201e28:	ff440413          	addi	s0,s0,-12 # ffffffffc0202e18 <default_pmm_manager+0x50>
            for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
ffffffffc0201e2c:	02800793          	li	a5,40
ffffffffc0201e30:	02800513          	li	a0,40
ffffffffc0201e34:	00140a13          	addi	s4,s0,1
ffffffffc0201e38:	bd6d                	j	ffffffffc0201cf2 <vprintfmt+0x204>
ffffffffc0201e3a:	00001a17          	auipc	s4,0x1
ffffffffc0201e3e:	fdfa0a13          	addi	s4,s4,-33 # ffffffffc0202e19 <default_pmm_manager+0x51>
ffffffffc0201e42:	02800513          	li	a0,40
ffffffffc0201e46:	02800793          	li	a5,40
                if (altflag && (ch < ' ' || ch > '~')) {
ffffffffc0201e4a:	05e00413          	li	s0,94
ffffffffc0201e4e:	b565                	j	ffffffffc0201cf6 <vprintfmt+0x208>

ffffffffc0201e50 <printfmt>:
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...) {
ffffffffc0201e50:	715d                	addi	sp,sp,-80
    va_start(ap, fmt);
ffffffffc0201e52:	02810313          	addi	t1,sp,40
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...) {
ffffffffc0201e56:	f436                	sd	a3,40(sp)
    vprintfmt(putch, putdat, fmt, ap);
ffffffffc0201e58:	869a                	mv	a3,t1
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...) {
ffffffffc0201e5a:	ec06                	sd	ra,24(sp)
ffffffffc0201e5c:	f83a                	sd	a4,48(sp)
ffffffffc0201e5e:	fc3e                	sd	a5,56(sp)
ffffffffc0201e60:	e0c2                	sd	a6,64(sp)
ffffffffc0201e62:	e4c6                	sd	a7,72(sp)
    va_start(ap, fmt);
ffffffffc0201e64:	e41a                	sd	t1,8(sp)
    vprintfmt(putch, putdat, fmt, ap);
ffffffffc0201e66:	c89ff0ef          	jal	ra,ffffffffc0201aee <vprintfmt>
}
ffffffffc0201e6a:	60e2                	ld	ra,24(sp)
ffffffffc0201e6c:	6161                	addi	sp,sp,80
ffffffffc0201e6e:	8082                	ret

ffffffffc0201e70 <readline>:
 * The readline() function returns the text of the line read. If some errors
 * are happened, NULL is returned. The return value is a global variable,
 * thus it should be copied before it is used.
 * */
char *
readline(const char *prompt) {
ffffffffc0201e70:	715d                	addi	sp,sp,-80
ffffffffc0201e72:	e486                	sd	ra,72(sp)
ffffffffc0201e74:	e0a6                	sd	s1,64(sp)
ffffffffc0201e76:	fc4a                	sd	s2,56(sp)
ffffffffc0201e78:	f84e                	sd	s3,48(sp)
ffffffffc0201e7a:	f452                	sd	s4,40(sp)
ffffffffc0201e7c:	f056                	sd	s5,32(sp)
ffffffffc0201e7e:	ec5a                	sd	s6,24(sp)
ffffffffc0201e80:	e85e                	sd	s7,16(sp)
    if (prompt != NULL) {
ffffffffc0201e82:	c901                	beqz	a0,ffffffffc0201e92 <readline+0x22>
ffffffffc0201e84:	85aa                	mv	a1,a0
        cprintf("%s", prompt);
ffffffffc0201e86:	00001517          	auipc	a0,0x1
ffffffffc0201e8a:	faa50513          	addi	a0,a0,-86 # ffffffffc0202e30 <default_pmm_manager+0x68>
ffffffffc0201e8e:	a52fe0ef          	jal	ra,ffffffffc02000e0 <cprintf>
readline(const char *prompt) {
ffffffffc0201e92:	4481                	li	s1,0
    while (1) {
        c = getchar();
        if (c < 0) {
            return NULL;
        }
        else if (c >= ' ' && i < BUFSIZE - 1) {
ffffffffc0201e94:	497d                	li	s2,31
            cputchar(c);
            buf[i ++] = c;
        }
        else if (c == '\b' && i > 0) {
ffffffffc0201e96:	49a1                	li	s3,8
            cputchar(c);
            i --;
        }
        else if (c == '\n' || c == '\r') {
ffffffffc0201e98:	4aa9                	li	s5,10
ffffffffc0201e9a:	4b35                	li	s6,13
            buf[i ++] = c;
ffffffffc0201e9c:	00005b97          	auipc	s7,0x5
ffffffffc0201ea0:	1a4b8b93          	addi	s7,s7,420 # ffffffffc0207040 <buf>
        else if (c >= ' ' && i < BUFSIZE - 1) {
ffffffffc0201ea4:	3fe00a13          	li	s4,1022
        c = getchar();
ffffffffc0201ea8:	ab0fe0ef          	jal	ra,ffffffffc0200158 <getchar>
        if (c < 0) {
ffffffffc0201eac:	00054a63          	bltz	a0,ffffffffc0201ec0 <readline+0x50>
        else if (c >= ' ' && i < BUFSIZE - 1) {
ffffffffc0201eb0:	00a95a63          	bge	s2,a0,ffffffffc0201ec4 <readline+0x54>
ffffffffc0201eb4:	029a5263          	bge	s4,s1,ffffffffc0201ed8 <readline+0x68>
        c = getchar();
ffffffffc0201eb8:	aa0fe0ef          	jal	ra,ffffffffc0200158 <getchar>
        if (c < 0) {
ffffffffc0201ebc:	fe055ae3          	bgez	a0,ffffffffc0201eb0 <readline+0x40>
            return NULL;
ffffffffc0201ec0:	4501                	li	a0,0
ffffffffc0201ec2:	a091                	j	ffffffffc0201f06 <readline+0x96>
        else if (c == '\b' && i > 0) {
ffffffffc0201ec4:	03351463          	bne	a0,s3,ffffffffc0201eec <readline+0x7c>
ffffffffc0201ec8:	e8a9                	bnez	s1,ffffffffc0201f1a <readline+0xaa>
        c = getchar();
ffffffffc0201eca:	a8efe0ef          	jal	ra,ffffffffc0200158 <getchar>
        if (c < 0) {
ffffffffc0201ece:	fe0549e3          	bltz	a0,ffffffffc0201ec0 <readline+0x50>
        else if (c >= ' ' && i < BUFSIZE - 1) {
ffffffffc0201ed2:	fea959e3          	bge	s2,a0,ffffffffc0201ec4 <readline+0x54>
ffffffffc0201ed6:	4481                	li	s1,0
            cputchar(c);
ffffffffc0201ed8:	e42a                	sd	a0,8(sp)
ffffffffc0201eda:	a3cfe0ef          	jal	ra,ffffffffc0200116 <cputchar>
            buf[i ++] = c;
ffffffffc0201ede:	6522                	ld	a0,8(sp)
ffffffffc0201ee0:	009b87b3          	add	a5,s7,s1
ffffffffc0201ee4:	2485                	addiw	s1,s1,1
ffffffffc0201ee6:	00a78023          	sb	a0,0(a5)
ffffffffc0201eea:	bf7d                	j	ffffffffc0201ea8 <readline+0x38>
        else if (c == '\n' || c == '\r') {
ffffffffc0201eec:	01550463          	beq	a0,s5,ffffffffc0201ef4 <readline+0x84>
ffffffffc0201ef0:	fb651ce3          	bne	a0,s6,ffffffffc0201ea8 <readline+0x38>
            cputchar(c);
ffffffffc0201ef4:	a22fe0ef          	jal	ra,ffffffffc0200116 <cputchar>
            buf[i] = '\0';
ffffffffc0201ef8:	00005517          	auipc	a0,0x5
ffffffffc0201efc:	14850513          	addi	a0,a0,328 # ffffffffc0207040 <buf>
ffffffffc0201f00:	94aa                	add	s1,s1,a0
ffffffffc0201f02:	00048023          	sb	zero,0(s1)
            return buf;
        }
    }
}
ffffffffc0201f06:	60a6                	ld	ra,72(sp)
ffffffffc0201f08:	6486                	ld	s1,64(sp)
ffffffffc0201f0a:	7962                	ld	s2,56(sp)
ffffffffc0201f0c:	79c2                	ld	s3,48(sp)
ffffffffc0201f0e:	7a22                	ld	s4,40(sp)
ffffffffc0201f10:	7a82                	ld	s5,32(sp)
ffffffffc0201f12:	6b62                	ld	s6,24(sp)
ffffffffc0201f14:	6bc2                	ld	s7,16(sp)
ffffffffc0201f16:	6161                	addi	sp,sp,80
ffffffffc0201f18:	8082                	ret
            cputchar(c);
ffffffffc0201f1a:	4521                	li	a0,8
ffffffffc0201f1c:	9fafe0ef          	jal	ra,ffffffffc0200116 <cputchar>
            i --;
ffffffffc0201f20:	34fd                	addiw	s1,s1,-1
ffffffffc0201f22:	b759                	j	ffffffffc0201ea8 <readline+0x38>

ffffffffc0201f24 <sbi_console_putchar>:
uint64_t SBI_REMOTE_SFENCE_VMA_ASID = 7;
uint64_t SBI_SHUTDOWN = 8;

uint64_t sbi_call(uint64_t sbi_type, uint64_t arg0, uint64_t arg1, uint64_t arg2) {
    uint64_t ret_val;
    __asm__ volatile (
ffffffffc0201f24:	4781                	li	a5,0
ffffffffc0201f26:	00005717          	auipc	a4,0x5
ffffffffc0201f2a:	0f273703          	ld	a4,242(a4) # ffffffffc0207018 <SBI_CONSOLE_PUTCHAR>
ffffffffc0201f2e:	88ba                	mv	a7,a4
ffffffffc0201f30:	852a                	mv	a0,a0
ffffffffc0201f32:	85be                	mv	a1,a5
ffffffffc0201f34:	863e                	mv	a2,a5
ffffffffc0201f36:	00000073          	ecall
ffffffffc0201f3a:	87aa                	mv	a5,a0
    return ret_val;
}

void sbi_console_putchar(unsigned char ch) {
    sbi_call(SBI_CONSOLE_PUTCHAR, ch, 0, 0);
}
ffffffffc0201f3c:	8082                	ret

ffffffffc0201f3e <sbi_set_timer>:
    __asm__ volatile (
ffffffffc0201f3e:	4781                	li	a5,0
ffffffffc0201f40:	00005717          	auipc	a4,0x5
ffffffffc0201f44:	53073703          	ld	a4,1328(a4) # ffffffffc0207470 <SBI_SET_TIMER>
ffffffffc0201f48:	88ba                	mv	a7,a4
ffffffffc0201f4a:	852a                	mv	a0,a0
ffffffffc0201f4c:	85be                	mv	a1,a5
ffffffffc0201f4e:	863e                	mv	a2,a5
ffffffffc0201f50:	00000073          	ecall
ffffffffc0201f54:	87aa                	mv	a5,a0

void sbi_set_timer(unsigned long long stime_value) {
    sbi_call(SBI_SET_TIMER, stime_value, 0, 0);
}
ffffffffc0201f56:	8082                	ret

ffffffffc0201f58 <sbi_console_getchar>:
    __asm__ volatile (
ffffffffc0201f58:	4501                	li	a0,0
ffffffffc0201f5a:	00005797          	auipc	a5,0x5
ffffffffc0201f5e:	0b67b783          	ld	a5,182(a5) # ffffffffc0207010 <SBI_CONSOLE_GETCHAR>
ffffffffc0201f62:	88be                	mv	a7,a5
ffffffffc0201f64:	852a                	mv	a0,a0
ffffffffc0201f66:	85aa                	mv	a1,a0
ffffffffc0201f68:	862a                	mv	a2,a0
ffffffffc0201f6a:	00000073          	ecall
ffffffffc0201f6e:	852a                	mv	a0,a0

int sbi_console_getchar(void) {
    return sbi_call(SBI_CONSOLE_GETCHAR, 0, 0, 0);
}
ffffffffc0201f70:	2501                	sext.w	a0,a0
ffffffffc0201f72:	8082                	ret

ffffffffc0201f74 <sbi_shutdown>:
    __asm__ volatile (
ffffffffc0201f74:	4781                	li	a5,0
ffffffffc0201f76:	00005717          	auipc	a4,0x5
ffffffffc0201f7a:	0aa73703          	ld	a4,170(a4) # ffffffffc0207020 <SBI_SHUTDOWN>
ffffffffc0201f7e:	88ba                	mv	a7,a4
ffffffffc0201f80:	853e                	mv	a0,a5
ffffffffc0201f82:	85be                	mv	a1,a5
ffffffffc0201f84:	863e                	mv	a2,a5
ffffffffc0201f86:	00000073          	ecall
ffffffffc0201f8a:	87aa                	mv	a5,a0

void sbi_shutdown(void)
{
	sbi_call(SBI_SHUTDOWN, 0, 0, 0);
ffffffffc0201f8c:	8082                	ret
